LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 09:27 AM   #1
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Rep: Reputation: 15
Awk help!!!


So here is what I am trying to get into now.....


Use the head and awk commands to print the name and birthdate of the first four characters (i.e. lines) in the sorted datafile created above. Add these 4 lines to your output file (aamilne.out).

And here is what I am trying...

head -4 aamilne.sorted | awk '{printf ($1, $4/n)}'

Any help??
 
Old 07-06-2010, 09:29 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,422

Rep: Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815
Hey doc, any query like this is always best suited to not only include what you have tried but a before and after of the data.
 
Old 07-06-2010, 09:29 AM   #3
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Original Poster
Rep: Reputation: 15
head -4 aamilne.sorted | awk '{printf ($1, $4/n)}'aamilne.sorted >> aamilne.out

I wrote it wrong above
 
Old 07-06-2010, 09:33 AM   #4
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Original Poster
Rep: Reputation: 15
cat aamilne.sorted

Christopher Robin|boy|birthday cake|11/2/1975
Eeyore|donkey|thistles|7/10/1865
Heffalump|scary flying elephant|honey|6/30/2006
Jagular|fierce big cat|honey|12/7/2006
Kanga|kangaroo|alphabet soup|2/22/1922
Owl|bird|small rodents|1/1/2000
Piglet|small pig|hay corns|4/47/1945
Pooh|bear|honey|5/14/1942
Rabbit|bunny rabbit|vegetable soup|12/7/1941
Roo|joey|apples|8/1/1950
Tigger|tiger|mud|1/1/2000
Wizzle|vicious relative of the woozle|honey|9/15/1966
Woozle|large weasel-shaped rodent|honey|9/12/2006

This is the before affect

The question is asking for this saved in my created vi file....


cat aamilne.sorted
Christopher Robin|11/2/1975
Eeyore|7/10/1865
Heffalump|honey|6/30/2006
Jagular|12/7/2006
Kanga|2/22/1922
Owl|1/1/2000
Piglet|4/47/1945
Pooh|5/14/1942
Rabbit|12/7/1941
Roo|8/1/1950
Tigger|1/1/2000
Wizzle|9/15/1966
Woozle|9/12/2006
 
Old 07-06-2010, 09:48 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,422

Rep: Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815
Right ... so first thing would be to throw head out as awk is all the too l you need:
Code:
awk -F"|" 'NR < 5{print $1,$4}' aamilne.sorted > aamilne.out
 
Old 07-06-2010, 10:44 AM   #6
Dru-Jitsu
Member
 
Registered: Jun 2010
Posts: 38

Original Poster
Rep: Reputation: 15
The instructions say I need to use the head command with the awk
 
Old 07-06-2010, 11:08 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,422

Rep: Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815
Well I am guessing it is some kind of lesson then, so you better do that. I think i have given enough that your task should be easily achievable.
 
  


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
[SOLVED] awk: how can I assign value to a shell variable inside awk? quanba Programming 6 03-23-2010 03:18 AM
awk , I need help for awk, just a display function mcandy General 1 12-15-2008 01:21 PM
shell command using awk fields inside awk one71 Programming 6 06-26-2008 05:11 PM
Some comments on awk and awk scripts makyo Programming 4 03-02-2008 06:39 PM


All times are GMT -5. The time now is 11:52 AM.

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