Home‎ > ‎

Fun with cvs and grep

posted Apr 12, 2011, 12:28 PM by Vishal Verma   [ updated Apr 12, 2011, 11:47 PM ]
I happen to work on a huge code base which has a gazillion files, and whenever I do a cvs update I'm forced to look at messages like :

 cvs update: Updating <path0> 
 cvs update: Updating <path1> 
 cvs update: Updating <path2> 
 cvs update: Updating <path3> 

which contain no changed files and tend to fill up my entire screen.
So I played around with piping the cvs output to grep and got some nicer results.

 ? build             
 ? logs              
 ? temp              
 M <path4>/<file0.c> 
 C <path5>/<file1.c> 
 P <path6>/<file2.c> 

This lists only the files that were added/modified etc. and gives me a much better idea of what has been changing.

Here's the command which I used - with some trial and error and a bit of Googling:

cvs up -P -d 2>&1 | grep -v "cvs update: "* | grep --color 'U \|P \|A \|R \|M \|C \|? '

and here's an explanation:

cvs update -P -d update, Prune empty directories, build new directories
2>&1pipe stderr also (cvs outputs to stderr, not stdout) 
grep -v "cvs update: "*  grep -v inverts grep, so discards all lines beginning with "cvs update: " (wildcard has to be outside quotes) 
grep --color 'U \|P \|A \|R \|M \|C \|? ' Optional, but colors the file 'status' (default red, set GREP_COLOR in env to change)