Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to strip headers from some files

Status
Not open for further replies.

fabien

Technical User
Sep 25, 2001
299
AU
Hello!

I would like to know how to strip headers from some files using AWK

The files look like with header starting with # for instance or it can just be a constant number of lines.

#jdksdjkdjs
#djskjdskds
#mdlsd
130.0 400.0 300.0
130.0 400.0 300.0
130.0 400.0 300.0

Thanks for your help!
 

Hi fabien!

Please, try this awk solution:

Code:
awk '/^#/ { next }  { print }' inputfile

Bye!

KP.
 
Hi Krunek!

Thanks it worked fine. What about if I want to take the first x lines out (they may not always start with #).

Thanks!

Fabien
 

Hi again Fabien!

Congratulations! Awk is a good choice for your problems.

You can take the first for example 3 lines of inputfile out with this awk solution:

Code:
awk &quot;NR <= 3&quot; inputfile

Good bless you! Bye!

KP.
 

Way the Bay, Fabien,

I use DOS version of awk. If you use *nix version of awk, awk script must be enclosed between single quotes, for example:

Code:
awk 'NR < 4' inputfile > outputfile

Bye again!

KP.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top