For Programmers: Free Programming Magazines  


Home > Archive > AWK > May 2005 > Re: Simple query how do I print a space after every second line









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Simple query how do I print a space after every second line
Ed Morton

2005-05-03, 8:55 pm



sammy wrote:

> Below works for each line but I would like every second line a space.
>
> awk '{print;print ""}' filname
>
> What I would like is below:
>
> start of day
> end of day
>
> start of day
> end of day
>
> Also I'd like to use a search critera as an option also ie search for say
> start and then print next two lines and have a space ie same
> as above output but using search. Something like below that does not work.
>
> awk '/start/ {print;print ""}'
>


awk '/start/{c=3}--c>=1;c==1{print "";c=0}'

Ed.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com