Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux系統常見問題解答 >> Linuxfind去除錯誤消息

Linuxfind去除錯誤消息

日期:2017/1/20 17:40:49      編輯: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

Copyright © Windows教程網 All Rights Reserved