LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-10-2007, 04:00 PM   #1
phyx
LQ Newbie
 
Registered: Jan 2006
Posts: 12

Rep: Reputation: 0
awk to remove first 3 lines and print remaining $1, $2 fields


How would I use awk to remove the first few lines while printing the fields on the remaining lines?

e.g.

Input data.in:
Header: This line is useless
Header2: This line is useless
Header3: This line is useless
John 24 32
Jane 21 33

Desired Output:
John 32
Jane 33


Current Script:
cat data.in | awk '{ if (FNR > 3) printf("%s %s\n", $1, $3) }


[NEVERMIND, got it.]

Last edited by phyx; 01-10-2007 at 04:04 PM.
 
Old 01-10-2007, 05:21 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
It's always nice to share your success!
At any rate, you don't need to use cat...
Code:
awk '{ if (FNR > 3) printf("%s %s\n", $1, $3) }' data.in
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk: remove similar lines from logfile peos Programming 7 06-19-2006 07:13 AM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 09:19 AM
awk print lines that doesn't have a pattern huynguye Programming 5 05-04-2006 11:08 AM
Supressing Fields w/ AWK Rv5 Programming 3 10-19-2004 11:06 AM
lines remaining when I launch an app or terminal spiteres Linux - General 0 05-27-2003 06:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration