[olug] Unix Tip: ECHO LINES TO A BLANK

Jay Hannah jay at jays.net
Sun Jun 22 16:03:54 UTC 2003


Ahh, perl's magical -p switch:

perl -pe 'exit if /^$/' <file_name>

Grin,

Jay Hannah
Omaha perl Mongers: http://omaha.pm.org


Unix Guru Universe wrote:
> ECHO LINES TO A BLANK
> 
> To echo all lines in a
> file upto the first blank
> line use the following:
> 
> awk '$0 ~ /^$/ {exit;} {print $0;}' <file_name>
> 
> The awk script can be used
> for printing lines upto the
> first occurence of any
> pattern.
> 
> Just substitute ^$ with
> the pattern.
> 
> I wrote this script to parse
> http server headers.
> 
> This tip generously supported by: anand at anandraman.net


More information about the OLUG mailing list