Results 1 to 2 of 2
When viewing a file, I use the following to produce the desired output:
cat file | awk '{print $2, $6, $7, $8, $9, $10, $12}'
I would like to use ...
- 02-04-2009 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 4
Grep help needed
When viewing a file, I use the following to produce the desired output:
cat file | awk '{print $2, $6, $7, $8, $9, $10, $12}'
I would like to use grep to only display when $2 is a particular value.
For example, if $2 is numeric, I may only want to see the output when $2 is 500.
Please advise.
Thanks
- 02-04-2009 #2
cat file | awk '$2 == "500" {print $2, $6, ..... $12}'
Basicaly this says
" if the second collum is equal to 500, than print yada yada."
awk uses a patern / command structure. if the patern is matched, perform what is in the { }, the default just matches everything.
I dont think you can restrict grep to a specific collum, but why would you want to, awk can do it just fine, and will do it faster (2 processes instead of one)New to the internet, technical forums, or the hacker / open source community??
Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html
RHCE for RHEL version 5
RHCT for RHEL version 4


Reply With Quote