Code Comments
Programming Forum and web based access to our favorite programming groups.Here's a little quickie I've found useful (I'm loving awk!).
I get files that have unix style linefeed-only and I can't edit them in
notepad.
After learning about awk, I just:
gawk "{print $0}" <infile.txt >outfile.txt
and it works like a champ!
Rufus
Post Follow-up to this message"Rufus V. Smith" <nospam@nospam.com> writes:
> Here's a little quickie I've found useful (I'm loving awk!).
>
> I get files that have unix style linefeed-only and I can't edit them in
> notepad.
>
> After learning about awk, I just:
>
> gawk "{print $0}" <infile.txt >outfile.txt
Alternatively, you can use the Shortest Program Ever:
gawk 1 infile.txt >outfile.txt
(Just as the empty pattern in your program always matches, the empty
action means "print $0".)
Just for the record.
Ulrich
--
"Stocks of combustible gases, such as carbon dioxide and helium, are
helping to fuel the flames making the blaze highly volatile."
-- Heard on MSNBC by RT, related in the sdm.
also at http://www.msnbc.com/news/954457.asp
Post Follow-up to this messageUlrich M. Schwarz <brotherelf@gmx.net> wrote: > "Rufus V. Smith" <nospam@nospam.com> writes: > > > Alternatively, you can use the Shortest Program Ever: > gawk 1 infile.txt >outfile.txt > (Just as the empty pattern in your program always matches, the empty > action means "print $0".) Hmm. The null program should be a valid awk program shouldn't it? Never do nothing. (gawk at least doesn't support it, which bothers me not at all)
Post Follow-up to this messageIn article <415dc52f$0$69739$ed2619ec@ptn-nntp-reader01.plus.net>, Ian Stirling <root@mauve.demon.co.uk> wrote: ... >The null program should be a valid awk program shouldn't it? >Never do nothing. > >(gawk at least doesn't support it, which bothers me not at all) "man gawk" contains this text: Either the pattern may be missing, or the action may be missing, but, of course, not both. I find no such language in "man awk" (on Solaris). But it is pretty obvious, else you couldn't have blank lines in your program...
Post Follow-up to this messageOn Fri, 01 Oct 2004 10:18:06 -0400, Rufus V. Smith wrote: > Here's a little quickie I've found useful (I'm loving awk!). > > I get files that have unix style linefeed-only and I can't edit them in > notepad. While I like awk and *nix tools, I would never have thought of that. I used to open any "questionable" files with wordpad, which I found could read *nix files, and after editing could store them in Windoze format(s). -- Juhan Leemet Logicognosis, Inc.
Post Follow-up to this messageKenny McCormack <gazelle@yin.interaccess.com> wrote: > In article <415dc52f$0$69739$ed2619ec@ptn-nntp-reader01.plus.net>, > Ian Stirling <root@mauve.demon.co.uk> wrote: > ... > > "man gawk" contains this text: > > Either the pattern may be missing, or the action may be missing, but, o f > course, not both. > > I find no such language in "man awk" (on Solaris). But it is pretty > obvious, else you couldn't have blank lines in your program... It would be a bit of computational overhead, but I can't see any side-effects. Thanks for pointing me at that bit of the manual, I somehow missed it when scanning through.
Post Follow-up to this messageOn 01 Oct 2004 20:59:28 GMT in comp.lang.awk, Ian Stirling
<root@mauve.demon.co.uk> wrote:
>Ulrich M. Schwarz <brotherelf@gmx.net> wrote:
>
>Hmm.
>The null program should be a valid awk program shouldn't it?
>Never do nothing.
>
>(gawk at least doesn't support it, which bothers me not at all)
gawk '' <anything or nothing>
just exits quietly (V3.1.1).
--
Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
Brian.Inglis@CSi.com (Brian[dot]Inglis{at}SystematicSW[dot]a
b[dot]ca)
fake address use address above to reply
Post Follow-up to this messageIn article <415dc52f$0$69739$ed2619ec@ptn-nntp-reader01.plus.net>, Ian Stirling <root@mauve.demon.co.uk> wrote: % The null program should be a valid awk program shouldn't it? % Never do nothing. Leaving aside the question of its validity as an awk program, although 0 characters is technically shorter than 1 character, the null program does require more typing, at least using my tool set. -- Patrick TJ McPhee East York Canada ptjm@interlog.com
Post Follow-up to this message"Rufus V. Smith" <nospam@nospam.com> writes:
> Here's a little quickie I've found useful (I'm loving awk!).
>
> I get files that have unix style linefeed-only and I can't edit them in
> notepad.
>
> After learning about awk, I just:
>
> gawk "{print $0}" <infile.txt >outfile.txt
Alternatively, you can use the Shortest Program Ever:
gawk 1 infile.txt >outfile.txt
(Just as the empty pattern in your program always matches, the empty
action means "print $0".)
Just for the record.
Ulrich
--
"Stocks of combustible gases, such as carbon dioxide and helium, are
helping to fuel the flames making the blaze highly volatile."
-- Heard on MSNBC by RT, related in the sdm.
also at http://www.msnbc.com/news/954457.asp
Post Follow-up to this messageUlrich M. Schwarz <brotherelf@gmx.net> wrote: > "Rufus V. Smith" <nospam@nospam.com> writes: > > > Alternatively, you can use the Shortest Program Ever: > gawk 1 infile.txt >outfile.txt > (Just as the empty pattern in your program always matches, the empty > action means "print $0".) Hmm. The null program should be a valid awk program shouldn't it? Never do nothing. (gawk at least doesn't support it, which bothers me not at all)
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.