Below awk command can be used to print particular column in command output or file.
To demonstrate this with an example, if you have file test.out with below content and 4 columns.
If you want to print second column in test.out file, your awk command looks as follows:
Below is example output of above command. As you can see it printed 2nd column.
cat <filename> | awk {'print $<column number>'}
<command> | awk {'print $<column number>'}
To demonstrate this with an example, if you have file test.out with below content and 4 columns.
A789652=alpha 22 33 44
A789651=alpha AA BB CC
A28ee69=beta XX YY ZZ
A28ee6a=beta 11 99 88
A2991a5=alpha 12 34 56
A789651=alpha AA BB CC
A28ee69=beta XX YY ZZ
A28ee6a=beta 11 99 88
A2991a5=alpha 12 34 56
If you want to print second column in test.out file, your awk command looks as follows:
# cat test.out | awk {'print $2'}
Below is example output of above command. As you can see it printed 2nd column.
22
AA
XX
11
12
AA
XX
11
12
Products to which Article Applies
All Linux Operating SystemsAdditional Reference
http://linuxcommand.org/lc3_adv_awk.php
tarun boyella
No comments:
Post a Comment