1830934 Members
2469 Online
110017 Solutions
New Discussion

Doubt in awk command

 
Nirmalkumar
Frequent Advisor

Doubt in awk command

Hi all,

column1
--------

33
44
55
66


In the above column1 the value 55 is unknown to me.In this case please provide the script to display 55 using awk command.


Help apperciated..

Thanks,
Nirmal
4 REPLIES 4
Sandman!
Honored Contributor

Re: Doubt in awk command

Please clarify what you mean by "the value 55 is unknown to me"? And assuming that you want to display the value 55 use the below awk construct:

# awk '$1==55' infile
Mel Burslan
Honored Contributor

Re: Doubt in awk command

if you know every other value but the 55, then, you can do something like this:

grep -v -e 33 -e 44 -e 66 /tmp/myfile

will only give you

column1
--------

55

output. It is not awk and it is not feasible in files which are not small, but since I don't know the nature of your request, this might be useful.
________________________________
UNIX because I majored in cryptology...
Sundar_7
Honored Contributor

Re: Doubt in awk command

Nirmal,

As with the above folks, I am not really sure what you are looking for.

If I were to make a wild guess, I think you want to print the first field of the third record in the file ?

# awk 'NR ==3 {print $1}' /inputfile

Sundar.
Learn What to do ,How to do and more importantly When to do ?
Arturo Galbiati
Esteemed Contributor

Re: Doubt in awk command

Hi Nirmal,
awk '/55/' infile

HTH,
Art