AWK - Hard to understand for me

Thread Tools Search this Thread
# 1  
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 Smilie

When I tried executing below command in the command prompt
awk' '{print$1}' SNA_DB_UPG.list

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

Further I felt better to give some file to print the output as below:
awk' '{print$1}' SNA_DB_UPG.list >> test

But Alas no luck.. Smilie

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

Thanks in Advance: Ambar
# 2  
we need to give space between the print and $1
print $1

# 3  
But still .. after giving space also .. It is not working for me.. Smilie
# 4  
just noticed..

please remove the highlighted single quote

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

This User Gave Thanks to itkamaraj For This Post:
# 5  
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 Smilie

Thanks again itkamaraj.. I really feel good after executing my first command using 'awk' Smilie
# 6  
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!
# 7  

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

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

It is requested to please explain me.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #330
Difficulty: Easy
The first dual-core CPU was the Intel Pentium D.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help understand awk command

Help understand awk command This command converts the column values to rows. Command: awk -s1=" " '{S=S?S OFS s1 $0 s1:s1 $0 s1} END{print S}' OFS=, Input_file Example: 1 2 3 is converted to: 1, 2, 3 Can anyone please help me understand this command? Please use code tags when... (1 Reply)
Discussion started by: mohan44
1 Replies

2. Shell Programming and Scripting

(hard one) awk, copy matching 2 col & 10-12 rows, is it possible?

Hey guys, my first post here. I'm trying to use awk to copy all matching paragraphs from one file The file looks like this : Test Case Number 990990003099 Card Type CCCC Transaction Type Sale Entry Mode Keyed Account Number 4099562299219923 Transaction Amount 78.88 Description lorem... (2 Replies)
Discussion started by: awkawed
2 Replies

3. UNIX for Dummies Questions & Answers

Unable to understand awk script.

Hi below is the samll awk script which i am not able to understand properly. here a bit confusion in 2nd line for me 1. why *\ is not used before . in second line as it was used in first line *\$*\. */ 2. why always \ is used in every first line 3. is there any specific meaning... (9 Replies)
Discussion started by: scriptor
9 Replies

4. Shell Programming and Scripting

awk doesn't understand 'read' statement!!!

While working on awk programming, i found that it doesn't understand 'read' statement. Then what's the use of 'continue' and 'break' statement in awk. For ex: awk '{k=1; while (k<10) {print $0; k++}}' emp.lst Now, please say if I want to put the logic that after priting 1 line, it will ask for... (13 Replies)
Discussion started by: ravisingh
13 Replies

5. Shell Programming and Scripting

Don't understand AWK asort behaviour

Hello, I have the following script : BEGIN { print "1 ***"; split("abc",T,""); T="e"; T="z"; T="y"; for (i in T) printf("%i:%s ",i,T); print ""; for (i=1; i<=length(T); i++) printf(T); print "" print "2 ***"; asort(T,U); for (i in U) printf("%i:%s ",i,U); ... (3 Replies)
Discussion started by: jgilot
3 Replies

6. Shell Programming and Scripting

Need help to understand Awk code.

Hi Guys, Can someone please explain this code to me. I could figure out it's adding and comparing two fields but I am not sure which ones. sort -t"|" -k3.1 /tmp/mpcashqc.xtr| awk -F"|" '{CHECKAMT+=$3;BATCHTOT=$4;\ items++}END{for(i in CHECKAMT) if (CHECKAMT!=BATCHTOT)... (6 Replies)
Discussion started by: nua7
6 Replies

7. Shell Programming and Scripting

Don't understand how RS functions in awk

I learn using RS in awk to extract portion of file in this forum which is wonderful solution to the problem. However, I don't understand how exactly it operates. I don't quite understand the mechanism behind how searching for /DATA2/ can result in extracting the whole section under "DATA2" ... (3 Replies)
Discussion started by: joe228
3 Replies

8. UNIX for Dummies Questions & Answers

unable to understand a awk code

i am not able to understand the following code for awk: $awk -F"|" '{ kount++} >END { for (desig in kount) > print desig,kount }' emp.list the input file i.e. emp.list is :: 3432| p.k.agrwal |g.m |sales 4566|g.l.sharma |director|production 3433|r shah | g.m | production... (1 Reply)
Discussion started by: streetfi8er
1 Replies

9. UNIX for Dummies Questions & Answers

Unable to understand associative nature of awk arrays

About associative nature of awk arrays i'm still confused, not able to understand yet how array element can be accessed based on a string, I got one example at gawk manual to illustrate associative nature of awk arrays, it goes here: Codeawk ' # Print list of word frequencies { for (i = 1;... (3 Replies)
Discussion started by: nervous
3 Replies

10. Filesystems, Disks and Memory

The best partitioning schem for a 250GB Sata hard drive & a 75GB SCSI hard drive

Hi I have 2 75GB SCSI hard drives and 2 250GB SATA hard drives which are using RAID Level 1 respectively. I wana have both FTP and Apache installed on them as services. I'm wondering what's the best partitioning schem? I wana use FC3 as my OS, so, I thought I can use the 75GB hard drive as the /... (0 Replies)
Discussion started by: sirbijan
0 Replies

Featured Tech Videos