+ -
当前位置:首页 → 问答吧 → 请问查找文件带空格的问题

请问查找文件带空格的问题

时间:2011-05-06

来源:互联网

我想查找某个目录下文件中包含某个字段的文件

我现在用的方法是 find path | xargs grep xxxx ,但是遇到文件路径中带空格的就不行了

请问大家有什么好办法能解决这个问题? 谢谢

作者: swizard   发布时间: 2011-05-06

  1. [root@bill cu]# find ./|xargs grep haha
  2. ./test2/1:haha
  3. ./test2/2:haha haha
  4. ./test2/4:haha haha haha haha
  5. ./test2/3:haha haha haha
  6. grep: ./file: No such file or directory
  7. grep: 2.txt: No such file or directory
  8. ./aa.sh:echo haha
  9. [root@bill cu]# find ./|sed 's/ /\\ /g'|xargs grep haha
  10. ./test2/1:haha
  11. ./test2/2:haha haha
  12. ./test2/4:haha haha haha haha
  13. ./test2/3:haha haha haha
  14. ./file 2.txt:haha
  15. ./aa.sh:echo haha
复制代码
试试看吧

作者: dzhxc   发布时间: 2011-05-06

作者: yanxt   发布时间: 2011-05-06