Grep for string only in validation files

How can I search for / grep for a line only from a list of files that are set in captivity. I can get a list of files that check me with this command: p4 open -a | grep "username" ..

+4
source share
1 answer

This should do it for you:

p4 opened -u <username> | cut -d "#" -f 1 | p4 -x - where | cut -d " " -f 3 | xargs grep <search string> 

Commands with channels perform the following actions:

  • Get files opened by user
  • Get only the depot path for each file
  • Get p4, where is the output, including the path to the local file in the third column
  • Cut output to get only local file path
  • Grep for your string.

Note that adding the -u option to p4 openly is a more efficient way to get files opened by a specific user than grepping the output "p4 open -a".

+4
source

Source: https://habr.com/ru/post/1395074/


All Articles