关于find .. | tar .. 的问题

来源:互联网 发布:男生文具盒淘宝 编辑:程序博客网 时间:2024/04/29 23:10

可以用下面的命令

find  -type f   -print0 |tar --null -cvf a.tar -T -

print0 表示打印文件列表 结尾是个null

--null 表示接受参数结尾是null

这主要是解决文件名中有空格的问题,也可以用在xargs命令中



解释在此,不翻译了

the best way to use find ... | xargs ... is to use the -print0/-0 parameter on each: find -print0 ... | xargs -0 .... This will cause the filenames to be separated by a null character, which means you can have spaces or newlines or other weird stuff in your filenames and it will still work.

 -T, --files-from FILE
           get names to extract or create from FILE


-I 参数

       -I replace-str
              Replace occurrences of replace-str in the initial-arguments with names read from standard input.  Also, unquoted blanks do not
              terminate input items; instead the separator is the newline character.  Implies -x and -L 1.


replace-str 一般用{} 即 -I {}

就是从标准输入读取 然后放到{}的位置上去.

find -name "libav*" |xargs -n 1 -I {} adb push {}  /system/lib/

原创粉丝点击