simple awk problem 
Author Message
 simple awk problem

I have a multi line text file. For every line that has a certain pattern in
it I would like to strip off the new line character.

   -**** Posted from RemarQ, http://www.*-*-*.com/ ****-
 Search and Read Usenet Discussions in your Browser - FREE -



Sun, 12 May 2002 03:00:00 GMT  
 simple awk problem

Quote:

>I have a multi line text file. For every line that has a certain pattern in
>it I would like to strip off the new line character.

{ printf $0}

$0 !~ /XXX/ { printf "\n"}



Sun, 12 May 2002 03:00:00 GMT  
 simple awk problem

Quote:

> I have a multi line text file. For every line that has a certain pattern in
> it I would like to strip off the new line character.

>    -**** Posted from RemarQ, http://www.remarq.com/?a ****-
>  Search and Read Usenet Discussions in your Browser - FREE -

gawk '{printf "%s%s",$0,(/pattern/ ? "" : "\n" ) }' infile
or
gawk '/pattern/ { printf "%s",$0 ;next } { print } ' infile
or
gawk '(ORS=( /pattern/? "" : "\n" ))||1' infile
or
gawk '{ORS=( /pattern/? "" : "\n" );print}' infile

goodluck,Eiso



Sun, 12 May 2002 03:00:00 GMT  
 simple awk problem

Quote:

> > I have a multi line text file. For every line that has a certain pattern
> > in it I would like to strip off the new line character.

> { printf $0}
> ...

Never a good idea. See URL <http://x46.deja.com/getdoc.xp?AN=478719318>.

--
Jim Monty

Tempe, Arizona USA



Mon, 13 May 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. A very simple question on SED or AWK for a GURU, and an enjoyable problem

2. Very simple awk for a simple user

3. Problem with simple AWK script.

4. Simple problem, simple solution.

5. Simple awk question

6. Help with A simple awk script.

7. A simple question regarding shell scripts and awk

8. Simple awk question

9. simple awk Q

10. Awk sub command -simple question for html

11. Simple awk command within a perl script

12. Simple Awk Question

 

 
Powered by phpBB® Forum Software