强大的管道符及组合命令

来源:互联网 发布:mac 10.11.6 升级包 编辑:程序博客网 时间:2024/06/05 22:43

管道符,可以把两条命令连起来,具体来说有两种应用,如下:

1. 例如: ps aux | grep "media"  在 ps aux中的結果中查找media。

2. 例如:   find . -name "*.cpp" | xargs grep "class" -n --color=auto   把find的结果当成参数传入到grep中,即在那些文件内部查找class关键字。


一个复杂的例子:

svn status | xargs -i expr substr {} 9 100 | xargs -i cp {} ~/Desktop/

find . -name "*.xml" | xargs grep  -l "com.lib.ui.common.TempTitle" | xargs -i  sed -i "s/com.lib.ui.common.TempTitle/com.common.widget.TempTitle/g"  {}


svn中显示buildversion的命令:

svn info | grep "Revision" | xargs -i  expr substr {} 11 100

0 0
原创粉丝点击