Make p4 for multiple files containing matching pattern

I have few files inside the folder. But some of the files contain a specific pattern within them. I want to grep these files and edit p4 in those files.

I have used this command on my terminal, but it doesn't work.

grep -rl "pattern" * | p4 edit

      

Note. I ended up in the folder that contains all the files.

thank

+3


source to share


3 answers


Pipe the grep output to xargs



grep -rl "pattern" * | xargs p4 edit

      

+5


source


The usual way to do it:

grep -rl "pattern" * | p4 -x - edit

      



p4 help usage

explains -x

:

The -x flag tells p4 to read arguments, one on each line, from the specified file. If you specify "-", standard input is read.

+2


source


I think this information might help someone. First run the following command to open all files.

p4 edit ...

      

Make your changes and run the following command to revert files that haven't changed.

p4 revert -a

      

0


source







All Articles