command for "strip out every line that doesn't contain xxxxx"
Ok, so I'm stringing together some line commands here. Is there a line command that will do the following:
Given some newline seperated data (such as ls -l ) that's piped in ( with | ), do the following: Remove every line that does NOT contain "abcdefg" on it. Or even better, could it remove every line that does not contain a regexp like /a*bcd(e|g)/; |
Yes. It's called grep. :)
Specifically, it PRINTS every line that DOES contain the expression. Use 'egrep' for the more extended regexps, like above. |
the -v option to grep will remove any line that contains the following exp. such as:
Code:
ls -l |grep -v whatever --Shade |
I think the OP wanted to remove those that do NOT contain the expression. Which would be equivalent to printing those that DO contain the expression. Hence, no -v.
|
Wow. I think you're right. These double negatives confuse me :)
--Shade |
Quote:
|
No problem. :) Don't be embarassed, I've asked plenty of obvious questions.
|
All times are GMT -5. The time now is 11:07 PM. |