简体   繁体   English

对包含匹配模式的多个文件执行p4编辑

[英]do p4 edit for multiple files which contain a matching pattern

I have few files inside a folder. 我文件夹里面的文件很少。 But some of the files contain a particular pattern inside them. 但是有些文件里面包含一个特定的模式。 I want to grep those files and do p4 edit on those files. 我想grep这些文件并对这些文件进行p4编辑。

I have used this command on my terminal, but it doesnt work. 我在终端上使用过这个命令,但它不起作用。

grep -rl "pattern" * | p4 edit

Note: I am inside the folder in which all the files reside. 注意:我在所有文件所在的文件夹中。

Thanks 谢谢

将grep的输出传递给xargs

grep -rl "pattern" * | xargs p4 edit

The normal way to do this is to do: 通常的做法是:

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

p4 help usage explains -x : p4 help usage说明-x

The -x flag instructs p4 to read the arguments, one per line, from the specified file. -x标志指示p4从指定文件中读取每行一个参数。 If you specify '-', standard input is read. 如果指定“ - ”,则读取标准输入。

I think this information is might useful to someone. 我认为这些信息可能对某人有用。 First run following command to open all files. 首先运行以下命令打开所有文件。

p4 edit ...

Make your changes and run following command to revert the files which are not modified. 进行更改并运行以下命令以还原未修改的文件。

p4 revert -a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM