Bash script - grep in a loop
For some reason i am struggling with the following.
I have a command that greps out data from a text file: Code:
cat file | grep Registration | awk '{print $3}' 10 11 22 32 I want to check if any of the values = 100 and then echo "Error" I know I need to use a for loop but then how do I specify the number of times to loop, and if I put the grep in the loop wont it only spit out the first match each time? |
Is this what you are looking for:
Code:
awk '/Registration/ { if ( $3 == "100" ) { print $3, "error" } else { print $3 } }' infile Code:
$ cat infile |
Thanks a lot! Perfect!
|
All times are GMT -5. The time now is 12:56 PM. |