LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   One more AWK question (https://www.linuxquestions.org/questions/linux-newbie-8/one-more-awk-question-818286/)

Dru-Jitsu 07-06-2010 10:55 AM

One more AWK question
 
After spending roughly 4 hours playing with awk I am stuck for the second time on something that I think I am over thinking this.


Determine how many lines are in your datafile. Then use the head, tail, and awk statements to print just the Character's birth year for the middle five data lines. Add these 5 lines to your output file.

ok so I have 13 lines in this file...

So I know that head is the first 10 of a file and tail is the last 10; so using these I am not sure how to tell it to hit those middle 4 lines, been reading and such and I just can't find it. There being 13 lines means theres 3 outside the head and 3 outside the tail... If anyone could touch on how you would use these commands to pull strings out of the middle I would greatly appreciate it, in the mean time I'll keep looking.

colucix 07-06-2010 11:01 AM

Did you look at the tail and head manual pages? Look carefully at the -n option. Nuff' said.

grail 07-06-2010 11:14 AM

Also might want to consider, what if you did not know how many lines there were??

Dru-Jitsu 07-06-2010 11:42 AM

so...

head -n -4 aamilne.sort | tail -n +4 aaamilne.sort ???


All times are GMT -5. The time now is 03:54 PM.