Avoiding junk character to using "grep and sed) command
Hi All,
I need help regarding to use grep command. I am using following grep command: grep 'notify@dtainc.us' virtual I want to extract all the mail id which contain "notify" in virtual file. right now if i am executing above command it's working fine but its coming with junk '#' header .. I want to avoid this '#' character in my output. see the result: ================================== $grep 'notify@dtainc.us' virtual # abc.notify@abc.us sddfd.notify@dtainc.us sdfdf@dtainc.us,dfd@dfd.com,Mende.Wi...@buyerzone.com # tibersoft.notify@dtainc.us ============================ Please help me ! Thanks in advance. Sanjeev |
My example:
$ cat txtex # txtex asdsf.notify@lkfgj.wq # # abc.notify@abc.us sddfd.notify@dtainc.us sdfdf@dtainc.us dfd@dfd.com # tibersoft.notify@dtainc.us Try this: $ grep -v "^#" txtex | grep notify@ asdsf.notify@lkfgj.wq sddfd.notify@dtainc.us |
Don't use either grep or sed for logical AND situations - awk is much neater and only reads the input once.
Code:
awk '!/^#/ && /notify@/' infile |
Well you could use sed, just a little trickier:
Code:
sed -n '/notify@/{/^#/!p}' file |
All times are GMT -5. The time now is 01:27 PM. |