Linuxfind去除错误消息下载
当Linux 进行查找时,对某些目录的访问可能没有权限而无法进行访问,打印出很多错误消息
1、root目录文件内容
-bash-3.2$ ls
anaconda-ks.cfg bea Desktop lib wls1036_generic.jar
2、查找.log结尾的文件,
-bash-3.2$ find . -name “*.log”
find: ./.gconfd: ?Ď
???¤Ÿ
find: ./.gnome2: ?Ď
???¤Ÿ
find: ./.gnome2_private: ?Ď
???¤Ÿ
find: ./.Trash: ?Ď
???¤Ÿ
find: ./.java: ?Ď
???¤Ÿ
find: ./.tuscany: ?Ď
???¤Ÿ
find: ./.eggcups: ?Ď
???¤Ÿ
find: ./.chewing: ?Ď
???¤Ÿ
find: ./.mozilla/firefox: ?Ď
???¤Ÿ
find: ./.scim: ?Ď
???¤Ÿ
find: ./.metacity: ?Ď
???¤Ÿ
find: ./.gconf: ?Ď
???¤Ÿ
find: ./.nautilus/metafiles: ?Ď
???¤Ÿ
这时系统语言使用中文反而有问题,很奇怪
-bash-3.2$ echo $LANG
zh_CN.UTF-8
临时改为英文
-bash-3.2$ export LANG=”en_US.UTF-8″
-bash-3.2$ echo $LANG
en_US.UTF-8
然后知识兔再查找
-bash-3.2$ find . -name “*.log”
find: ./.gconfd: Permission denied
find: ./.gnome2: Permission denied
find: ./.gnome2_private: Permission denied
find: ./.Trash: Permission denied
find: ./.java: Permission denied
find: ./.tuscany: Permission denied
find: ./.eggcups: Permission denied
find: ./.chewing: Permission denied
find: ./.mozilla/firefox: Permission denied
find: ./.scim: Permission denied
find: ./.metacity: Permission denied
find: ./.gconf: Permission denied
find: ./.nautilus/metafiles: Permission denied
3、知识兔将错误输出到/dev/null装置上,错误信息消失
-bash-3.2$ find . -name “*.log” 2>/dev/null
-bash-3.2$ find . -name “*.cfg” 2>/dev/null
./anaconda-ks.cfg
本文来自系统大全为您分享如需转载请注明!推荐win10下载
下载仅供下载体验和测试学习,不得商用和正当使用。