I’m new to regular expressions and grep, but I’ve been trying to learn it to help me when using console tools.
I have to use cvs, and when I update some files, I don’t need to see files that were’t updated or with *.pyc extension for example. So, I created a script that calls:
cvs update -d | grep -v 'pyc$' | grep -v '^\?'
First question: why cvs update -d | grep -v '(pyc$|^\?)' dooesn’t work, so I need to use cvs update -d | grep -v 'pyc$' | grep -v '^\?'?
Second question: files that weren’t updated start with a line:
-f update: Updating FILE
I tried grep -v '^\-f' and grep -v '^-f', but no luck. What is wrong with my expression? Is it a regular expression problem or something about Linux that I’m not aware of?
Thanks!
Answers only a part of your question:
You should try egrep instead of grep since
|(alternation) and( )(grouping) are only supported by egrep.EDIT:
The 2nd issue could occur since cvs writes some lines to stderr so you would need to redirect stderr to stdout by appending
2>&1to you command.