开发者

Searching the head of CVS

I'm looking for a 'relatively' easy way to search through cvs to look for a particular string in the HEAD revisions.

I realize the way CVS stores versions makes this difficult. But I'm trying to come up with some script to allow this search (performance is not expected here).

Currently this command will output the contents of the head files cvs co -r HEAD -p

stdout = file contents (to be grepped for the search string) stderr = the file name/header info (to be grepped for the line that signifies file name).

Ideally, I want to grep the contents and display the header + a few lines before and after the searched item (the output of this likely directed to some file).

I found a way to grep the stdout and stderr using different values. And the resulting stdout/stderr displayed is in the right order. But any attempt to redirect it to a file messes up the order?

{
  { cvs co -r HEAD -p myModule 4>&- | grep 'myString' 2>&4 4>&-
  } 4>&2 2>&1 >&3 3>&- | grep 'Check' >&2 开发者_如何转开发3>&-
} 3>&1

Question 1. Is there an easier way to do this all together?

Question 2. If not, how do I get the output of the code above to append to a file in the same order as displayed on the console?


Here are couple of suggestions:

  • You can use the "script" command to log your session in the right order. (See: 'man script')
  • For grep, if you want to insert context, you can use the -A, -B, -C options. (See: 'man grep', look for 'Context Line Control'.

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜