Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

changing lf-only to crlf
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



Report this thread to moderator Post Follow-up to this message
Old Post
Rufus V. Smith
10-02-04 01:56 PM


Re: changing lf-only to crlf
"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

Report this thread to moderator Post Follow-up to this message
Old Post
Ulrich M. Schwarz
10-02-04 01:56 PM


Re: changing lf-only to crlf
Ulrich 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)

Report this thread to moderator Post Follow-up to this message
Old Post
Ian Stirling
10-02-04 01:56 PM


Re: changing lf-only to crlf
In 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...


Report this thread to moderator Post Follow-up to this message
Old Post
Kenny McCormack
10-02-04 01:56 PM


Re: changing lf-only to crlf
On 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.



Report this thread to moderator Post Follow-up to this message
Old Post
Juhan Leemet
10-02-04 01:56 PM


Re: changing lf-only to crlf
Kenny 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Ian Stirling
10-02-04 01:56 PM


Re: changing lf-only to crlf
On 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

Report this thread to moderator Post Follow-up to this message
Old Post
Brian Inglis
10-02-04 08:55 PM


Re: changing lf-only to crlf
In 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

Report this thread to moderator Post Follow-up to this message
Old Post
Patrick TJ McPhee
10-03-04 01:55 AM


Re: changing lf-only to crlf
"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

Report this thread to moderator Post Follow-up to this message
Old Post
Ulrich M. Schwarz
10-04-04 08:55 AM


Re: changing lf-only to crlf
Ulrich 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)

Report this thread to moderator Post Follow-up to this message
Old Post
Ian Stirling
10-04-04 01:55 PM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:50 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.