Linux 中find命令未找到时不显示错误信息
001、
[root@pc1 test]# ls a.txt b.txt c.txt d.txt e.txt f.txt g.txt h.txt index.txt [root@pc1 test]# cat index.txt ## 查找的索引文件 a.txt b.txt x.txt y.txt c.txt z.txt d.txt [root@pc1 test]# for i in $(cat index.txt); do find ${i}*; done ## 一般查找,未找到则返回错误信息 a.txt b.txt find: ‘x.txt*’: No such file or directory find: ‘y.txt*’: No such file or directory c.txt find: ‘z.txt*’: No such file or directory d.txt [root@pc1 test]# for i in $(cat index.txt); do find ${i}* 2> /dev/null; done ## 错误重定向到 /dev/null a.txt b.txt c.txt d.txt
。