I want to print a line if i dont find the pattern using grep.! how is this possible?
i want to print " -- " if the grep command is not able to find a pattern!
how can i do it? so instead of disturbing my list of names...i can put "--" in that row. Thank you in advance! :) |
Hmm, grep(1). I think I'd use awk(1) or perl(1) instead for this one.
Code:
$ cat names.txt Code:
$ awk '{ if($0 ~ /^sa/) print ; else print "--" }' names.txt |
suppose i have a file in which there is a pattern
0001p0d5: vswr : 26.5[dB] but sumtyms der is a pattern 0001p0d5: vswr : value not generated so in the second case i need to print "--" instead of the value.. then? |
That's a simple extension of my first example.
Code:
$ cat names.txt Code:
$ awk '{ if($0 ~ /value not generated/) print "--" ; else print }' names.txt |
ohh..! this will help me for sure.! :)
thanks a lot.! |
All times are GMT -5. The time now is 11:45 PM. |