plese explain awk '{print \$NF}'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting plese explain awk '{print \$NF}'
# 1  
Old 04-04-2008
plese explain awk '{print \$NF}'

please explain this awk '{print \$NF}'

i have a command

grep -i adding /logs/eap | grep -iv equation | awk '{print \$NF}' | sort -u | sed 's/\.\$//' >> /temp/t


please explain the above awk and sed
as well how it works

and also what is \$NF
# 2  
Old 04-04-2008
Quote:
Originally Posted by mail2sant
please explain this awk '{print \$NF}'

i have a command

grep -i adding /logs/eap | grep -iv equation | awk '{print \$NF}' | sort -u | sed 's/\.\$//' >> /temp/t


please explain the above awk and sed
as well how it works

and also what is \$NF
The \ is irrelevant! It may be there to indicate that it is part of the same statement (if on two lines).

- The awk '{print $NF}' means print the last field in a space delemmited file.

- Sort -u sort the file, print one recird of each occurence (unique)

- The sed looks likes its trying to replace "." and "$" with nothing.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Please explain the use of quotes in awk command in below example-

Example: `abc.ksh | grep '^GLIS'| awk -F' ' '{print \$1}'`; (3 Replies)
Discussion started by: Tanu
3 Replies

2. Shell Programming and Scripting

Explain awk

I have 2 files recevied abc def ghi totallist abc 123 jasdhfaj def 345 fjdgkfsfh ghi 567 dfjdhdhfj jkl 678 djkahfdjshdf xyz 984 jdfdhfhdh myOutputFile jkl 678 djkahfdjshdf xyz 984 jdfdhfhdh I used this command for the output : awk 'FNR==NR {f1;next} !($1 in f1)' recevied... (2 Replies)
Discussion started by: nani1984
2 Replies

3. Shell Programming and Scripting

Explain this awk

found this handy one liner in another thread which is closed, it does what i need but im trying to understand it. it basically matches the field that contains the value v and prints its position awk -F, '{for(i=1;i<=NF;i++)if($i==v)print i}' v=yourfield inputfile my understanding is assign... (3 Replies)
Discussion started by: jack.bauer
3 Replies

4. Shell Programming and Scripting

Please explain what this Awk code is doing

Hi Guys, Please help me, I am new to programming and I don’t understand what some parts of this code are doing. I have comments on the parts I know, please help if my understanding of the code is not correct and also help with parts with questions. awk ' { gsub( ">",... (1 Reply)
Discussion started by: James_Owen
1 Replies

5. UNIX for Dummies Questions & Answers

Please explain this simple AWK example

awk '!_++' Most importantly, I want to know what the underscore does "!_" But ideally, please breakdown the whole thing. It is supposed to remove duplicate lines when found in a file. (1 Reply)
Discussion started by: glev2005
1 Replies

6. Shell Programming and Scripting

plese help me to solve this

i have 2 input files 1st file is N1 | N2|N3|N4|N5|N6|N7|N8|N9 4041491000|245160|1|0|0|1|0|0|0 4041401505|152178|1|1|1|1|0|0|0 4041450004|014052|1|1|1|1|0|0|0 4041450005|580916|1|1|1|1|0|0|0 4041491000|230990|1|0|1|1|0|0|0 4041460001|338317|1|1|1|1|0|0|0 2nd file N1 |... (1 Reply)
Discussion started by: dodasajan
1 Replies

7. Shell Programming and Scripting

AWK - HELP pls explain this ?

echo "23.54" | awk ' function round(A) { return int( A + 0.5 ) } { printf("%d\n",round($1)); }'> > > > > > awk: syntax error near line 2 awk: bailing out near line 2 (2 Replies)
Discussion started by: santosh1234
2 Replies

8. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

9. Shell Programming and Scripting

Explain awk

Hi, I found this command in this forum, but, couldnt understand much from it. could any one help me understand that??? the commands are : awk '{sub(/ ~/,""); printf $0 ($0~/\|$/?ORS:"")}' file1 > file2 awk '{sub(/~ */,x);printf $0(/\|$/?ORS:x)}' awk '{sub(/~ */,x);sub(/\|$/, "|\n")}8'... (4 Replies)
Discussion started by: hitmansilentass
4 Replies
Login or Register to Ask a Question