Linux find to remove error messages, linuxfind
In Linux, access to some directories may not be permitted, and many error messages may be printed.
1. root directory file content
-Bash-3.2 $ ls
Anaconda-ks.cfg bea Desktop lib wls1036_generic.jar.
2. Search for the file ending with. log,
-Bash-3.2 $ find.-name "*. log"
Find:./. gconfd: zookeeper.™ ä ~~~~~~~~
Find:./. gnome2: ***é™ ä ~~~~~~~~
Find:./. gnome2_private: æ ƒ é™ ä ~~~~~~~~
Find:./. Trash: ****é™ ä ~~~~~~~~
Find:./. java: æ ƒ é™ ä ~~~~~~~~
Find:./. tuscany: zookeeper é™ ä ~~~~~~~~
Find:./. eggcups: æ ƒ é™ ä ~~~~~~~~
Find:./. chewing: zookeeper™ ä ~~~~~~~~
Find:./. mozilla/firefox: æ ƒ é™ ä ~~~~~~~~
Find:./. scim: ****é™ ä ~~~~~~~~
Find:./. metacity: specified ***é™ ä ~~~~~~~~
Find:./. gconf: ****é™ ä ~~~~~~~~
Find:./. nautilus/metafiles: ****é™ ä ~~~~~~~~
At this time, the system language uses Chinese, but there is a problem, very strange
-Bash-3.2 $ echo $ LANG
Zh_CN.UTF-8
Temporarily changed to English
-Bash-3.2 $ export LANG = "en_US.UTF-8"
-Bash-3.2 $ echo $ LANG
En_US.UTF-8
Then search
-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. output the error to the/dev/null device, and the error message disappears.
-Bash-3.2 $ find.-name "*. log" 2>/dev/null
-Bash-3.2 $ find.-name "*. cfg" 2>/dev/null
/Anaconda-ks.cfg
How does linux shell remove the error message?
You can perform a redirection to shield the information, for example,>/dev/null 2> & 1
The Linux find command searches the directory to find out why there is no error with no permission.
If the user you are currently logged on to does not have the readable or executable permission for the searched directory
This error is reported.