LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-06-2010, 11:55 AM   #1
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Rep: Reputation: 15
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.
 
Old 07-06-2010, 12:01 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Did you look at the tail and head manual pages? Look carefully at the -n option. Nuff' said.
 
Old 07-06-2010, 12:14 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,552

Rep: Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898
Also might want to consider, what if you did not know how many lines there were??
 
Old 07-06-2010, 12:42 PM   #4
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Original Poster
Rep: Reputation: 15
so...

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk question on handling *.CSV "text fields" in awk jschiwal Programming 8 05-27-2010 07:23 AM
awk question cmontr Programming 12 11-19-2007 12:35 PM
an awk question zoshr Programming 5 04-13-2007 06:29 AM
Awk question blanny Linux - Software 6 05-02-2006 09:03 AM
awk question dilberim82 Programming 2 10-01-2003 08:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:54 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration