Also, if the line can be broken into several lines, the line
break occuring at each of those ^M characters, then that would be fine
too.
I tried breaking the lines at each of the ^M chars. using sed.
But, sed, too, doesn't seem to understand ^M's.
Thank you for your time.
Madhusudhan Reddy
Try the following command:
awk -F^M '{ for ( i=1 ; i<=NF ; i++ ) print $i }' < inputfile
Please be sure to enter the ^M as ( control-v control-m )
The control-v escapes the following control character. This works
with the vi editor or at the /bin/sh or /bin/ksh. If you use emacs,
it may be ( control-q control-m ) if i am right.
Not a bad attempt for an Aggie :-). Try using tr instead. One of these
should do the trick for you:
cat junk | tr \015 \012 > | goodfile
cat junk | tr '\015' '\012' | goodfile
After this, goodfile will have newlines in place of the ^M chars.
---
Jim jda...@asic.sc.ti.com
We didn't attack you for your views. We made fun of you,
because you are an idiot. -- Thayne Forbes
Woops. Try ">" instead of the second "|". Or avoiding cat altogether:
tr '\015' '\012' <junk >goodfile
--
J Lee Jaap <J.L....@LaRC.NASA.Gov> +1 804/864-2148
employed by, not necessarily speaking for, AS&M Inc,
at NASA LaRC, Hampton VA 23681-0001
mark
>Hello,
> Would anyone let me know how to set the Record Separator to
>"\^M" (i.e., CTRL-M) character.
In Aho etal, "The AWK programming language" p31 it says that
control characters can be represented by their octal number (in
much the same way as the 'tr' function in UNIX). For ^M (and a
few other characters) escape sequences have been defined. I
think it's \r (carriage return) for ^M.
Good luck,
Des
--
......o.......oo........ooo........oo0|0oo........ooo........oo.......o.......
Dr Des Costello, Department of Chemical Engineering, University of Edinburgh
phone: +44 (31) 650 5891, or e-mail to: d...@chemeng.ed.ac.uk
Correct about the octal representation. Note that this is, as far
as I know, only true for New Awk (nawk), of which gawk (GNU Awk) is
an instance. ^M is ASCII number 13, so in octal we have \015 (right?)
In fact, it would be handy when asking questions about awk if people
could try to distinguish between oawk and nawk ...
-- Charlie (who still has a soft spot for awk, despite being into perl
these days)
I suggest you do the same. "^M" may be a notational feature of some awk
you use, but manual I have doesn't allow that syntax.
mark
>In fact, it would be handy when asking questions about awk if people
>could try to distinguish between oawk and nawk ...
I agree, altough I don't do it al the time. Talking about different awk's,
is there anybody who has experience with the Thompson Automation, Inc
AWK compiler for dos. It's an awk compiler for dos for about $250,-. It has
the capability to generate object code that can be linked in with
Microsoft C object's.
>-- Charlie (who still has a soft spot for awk, despite being into perl
> these days)
Does it have to be the one or the other? Don't leave. The aren't to many
awk people around, so every one is needed.
Taeke
I use (and love) Thompson Automation's awk. The only problem with it is
the numerous features they added. I'm not so much concerned about portability
in my environment, but occasionally I'll use a non-standard extension in
Thompson Automation's awk that won't work on other systems.
The ability to link in 'C' code is a thrill. The demo that comes with
the package features calls to Microsoft's graphics library, but I've used it
to access NetBIOS, mouse, and MIDI routines I've written.
I'd be happy to answer any specific questions about Thompson Automation's
awk.
>>-- Charlie (who still has a soft spot for awk, despite being into perl
>> these days)
>
> Does it have to be the one or the other? Don't leave. The aren't to many
> awk people around, so every one is needed.
My initial look at the syntax for perl leaves me cold. I should probably
pick up the O'Reily "nutshell" book, but so far I haven't found anything I
can't do (or want to do) in awk (especially Thompson Automation's version)
that perl offers.