LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   awk to remove first 3 lines and print remaining $1, $2 fields (https://www.linuxquestions.org/questions/linux-general-1/awk-to-remove-first-3-lines-and-print-remaining-%241-%242-fields-518134/)

phyx 01-10-2007 04:00 PM

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.]

homey 01-10-2007 05:21 PM

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


All times are GMT -5. The time now is 10:37 AM.