本文介绍了SED - “文件名太长"- 有没有办法跳过这个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行这个命令:
cd /tmp;find / -maxdepth 2 -type f | xargs -0 sed -i 's/teststring1/finally/g'
它会一直处理直到报告错误:文件名太长.查找文档,似乎文件名超过 1024 字节.无论如何,我认为使用 print 0 会抑制这一点,但不会.是否有任何命令可以跳过错误而不仅仅是停止?
It processes until it comes to a point where it reports an error: file name too long. Looking up the docs, it seems like it is when there is a file name longer than 1024 bytes. Anyway, I thought using print 0 would supress this, but no. Are there any commands to skip errors rather than just stop?
推荐答案
cd /tmp;
find / -maxdepth 2 -type f -exec sed -i 's/teststring1/finally/g' {} \;
{}
将更改为每个文件名,甚至适用于名称中包含空格的文件.
The {}
will be changed to each filename, and works even for files with spaces in their names.
这篇关于SED - “文件名太长"- 有没有办法跳过这个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!