您的位置:首页 > 其它

mac下find: -exec: no terminating ";" or "+"的解决方法

2016-05-02 11:46 483 查看

如果想从一个含有很多文件的目录中拷贝指定文件去另一个目录,会报以下错误:

$ ls *_text.jpg
argument list too long: ls
$ cp *_text.jpg ~/Desktop/word
argument list too long: cp


这报的错误其实是提示你ls或者cp的文件过多,而不是命令的参数过长。解决方法如下,可以配合find && exec完成。

$ find . -name "*_text.jpg" -exec cp {}  ~/Desktop/word (查找当前目录下文件名包含_text.jpg的所有文件,拷贝到~/Desktop/word目录中,其中{}是find命令查找出来的所有结果)
find: -exec: no terminating ";" or "+"


出现
find: -exec: no terminating ";" or "+"
的问题,解决方法很简单,在命令尾部加一个” \;”。也就是:

$ find . -name "*_text.jpg" -exec cp {}  ~/Desktop/word \;


不仅如此,还可以取反转换成tif格式试试~

$ find . -name "*_text.jpg" -exec convert -negate {}  ~/Desktop/word/{}.tif \;


当然,也可以用脚本实现
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: