码迷,mamicode.com
首页 > 系统相关 > 详细

Linux find 去除错误消息

时间:2014-07-16 17:27:01      阅读:433      评论:0      收藏:0      [点我收藏+]

标签:linux   查找   

当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

Linux find 去除错误消息,布布扣,bubuko.com

Linux find 去除错误消息

标签:linux   查找   

原文地址:http://blog.csdn.net/hongweigg/article/details/37818697

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!