1

I am trying to change the copyrights in a repository, i mean change the old copyrights to new copyrights for example copyrights 2008 to copyrights 2012,

so what i want to do is to find,

  1. How many files have 2 copyrights
  2. How many files do not have any copyrights in them
  3. How many files have single, old copyrights in them

I was able to achieve questions 2 by using grep -vir copyright *, and question 3 by using grep -rni copyright *

how do I list out all the files with 2 copyrights in them?

4

3 回答 3

2

想必3、4或更多的版权和2一样麻烦?

您可以使用grep计数,然后再次过滤掉 1 的计数:

grep -irc copyright * | grep -v '^ *1 '
于 2012-09-14T21:58:35.597 回答
0

Use uniq with the -c flag. i.e. grep copyright * | uniq -c | egrep -v '^1'

于 2012-09-14T21:45:25.020 回答
0

用于xargs获取所有文件的版权行数:

ls * | xargs -I % sh -c "echo %; grep -c 'copyright' %"
于 2012-09-14T22:02:26.900 回答