Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

chomp a newline in awk

by Anonymous Monk
on Jan 18, 2001 at 07:55 UTC ( [id://52685]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re (tilly) 1: chomp a newline in awk
by tilly (Archbishop) on Jan 18, 2001 at 08:20 UTC
    Run a2p to convert to a less awk-ward language, then do it in Perl with chomp...
Re: chomp a newline in awk
by eg (Friar) on Jan 18, 2001 at 08:25 UTC

    Ewww. awk.

    gsub( "\n", "" );

    will remove all newlines in $0, if that's what you're looking for. I suppose you could anchor it with $

    gsub( /\n$/, "" );

    to be more like chomp.

    update: Oops! Looks like a is right. I based my assertion on the fact that

    % cat foo | awk '{ gsub(/\n$/,""); printf("%s", $0); }'

    printed out foo as a single line. But take out the gsub and you're okay too. Oh well.

      Doesn't awk (nawk) automatically chomp? 'least-wise, all my scripts (whoops - old scripts, really ;-) never worry about it: print adds \n back automatically.

      a

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://52685]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-19 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found