Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-15-2012
Registered User
 
Join Date: Dec 2011
Location: Bangalore
Posts: 35
Thanks: 27
Thanked 2 Times in 1 Post
AWK - Hard to understand for me

Hi All,

I have googled and spent few hours to understand about AWK usage... But still not very much clear....

Upto my understanding 'AWK' deals with files... It reads the file takes it as a input process it and gives output or writes the output to an another file...

>> Please correct me if I am wrong OR make me more clear and precise

When I tried executing below command in the command prompt

Code:
awk' '{print$1}' SNA_DB_UPG.list

It does not take this as a command and further seeking for a terminator...

Further I felt better to give some file to print the output as below:

Code:
awk' '{print$1}' SNA_DB_UPG.list >> test

But Alas no luck..

Please share few more examples... I gone through with older posts as well.. But nothing clicked me..

Thanks in Advance: Ambar
Sponsored Links
    #2  
Old 03-15-2012
itkamaraj's Avatar
^Kamaraj^
 
Join Date: Apr 2010
Posts: 3,025
Thanks: 33
Thanked 647 Times in 625 Posts
we need to give space between the print and $1

Code:
 
print $1

Sponsored Links
    #3  
Old 03-15-2012
Registered User
 
Join Date: Dec 2011
Location: Bangalore
Posts: 35
Thanks: 27
Thanked 2 Times in 1 Post
But still .. after giving space also .. It is not working for me..
    #4  
Old 03-15-2012
itkamaraj's Avatar
^Kamaraj^
 
Join Date: Apr 2010
Posts: 3,025
Thanks: 33
Thanked 647 Times in 625 Posts
just noticed..

please remove the highlighted single quote


Code:
 
awk' '{print $1}' SNA_DB_UPG.list

The Following User Says Thank You to itkamaraj For This Useful Post:
ambarginni (03-15-2012)
Sponsored Links
    #5  
Old 03-15-2012
Registered User
 
Join Date: Dec 2011
Location: Bangalore
Posts: 35
Thanks: 27
Thanked 2 Times in 1 Post
Thanks itkamaraj

Now it worked!! Thank you very much...

But can you please elaborate me with the logic as well.. As i am trying to understand the 'AWK'... what is all about - I know it is huge topic but the basic understanding so that I can read it further in google

Thanks again itkamaraj.. I really feel good after executing my first command using 'awk'
Sponsored Links
    #6  
Old 03-15-2012
itkamaraj's Avatar
^Kamaraj^
 
Join Date: Apr 2010
Posts: 3,025
Thanks: 33
Thanked 647 Times in 625 Posts
you can learn more in this page ( very good for awk and sed commands )

Awk - A Tutorial and Introduction - by Bruce Barnett
Welcome to The UNIX Grymoire!
Sponsored Links
    #7  
Old 03-15-2012
Registered User
 
Join Date: Dec 2011
Location: Bangalore
Posts: 35
Thanks: 27
Thanked 2 Times in 1 Post
Power

When I executed the below code in command prompt again the same problem.... Seeking for a delimiter and not taking the below as a executable code


Code:
BEGIN { print "SNA_DB_UPG.list"," }
{ print $8, "\t", $3}
END { print " - DONE -" }


It is requested to please explain me.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
can't understand! nikki1200 Shell Programming and Scripting 3 08-12-2011 04:29 AM
C++ Code to Access Linux Hard Disk Sectors (with a LoopBack Virtual Hard Disk) shen747 Linux 23 01-28-2011 09:27 PM
trying to understand what sed is doing? TheBigAmbulance Shell Programming and Scripting 2 06-29-2009 02:07 PM
The best partitioning schem for a 250GB Sata hard drive & a 75GB SCSI hard drive sirbijan Filesystems, Disks and Memory 0 04-05-2006 02:19 PM



All times are GMT -4. The time now is 04:02 AM.