Method of using find command to find hidden files in Linux

Time:2021-11-25

We can use the find command on Linux or UNIX systems to query all (all) hidden files

The basic syntax is as follows:

Copy code

The code is as follows:

[ [email protected] ~]#Find / file / folder to find / – name “. *” – Print

Explanation:

1. “. *” indicates the file name to be searched. Because the hidden file and folder names of Linux / Unix start with “.”. The * indicates wildcard, which means to find all file names and folder names, and start with “.”.
2. – print means to print the search result. Same function as – LS

perhaps

Copy code

The code is as follows:

[ [email protected] ~]#Find / file / folder to find / – name “. *” – LS

Or search only for hidden files:

Copy code

The code is as follows:

[ [email protected] ~]#Find / file / folder to find / – type F – Iname “. *” – LS

Or search only hidden folders:

Copy code

The code is as follows:

[ [email protected] ~]#Find / file / folder to find / – type D – Iname “. *” – LS

Explanation:
-Type: Specifies the type of file to search, whether it is a folder or a file. It should be used with f or D
f: It means file. The English of the file is file.
D: it means folder. The English name of the folder is directory
-Iname: indicates that case is ignored when matching file names. For example, find “fo *”, then “foo” and “foo” will match.

perhaps

Copy code

The code is as follows:

[ [email protected] ~]#Find / file / folder to find / – path ‘* /. *’ – Print</p>

For the explanation of the – path parameter, see another article “explanation of the function (meaning) of the – path parameter in the find command”

 

In the following example, find all hidden files and folders under $home ($home is the user’s home directory, you can use the echo $home command to view it, and you will understand the meaning)

Copy code

The code is as follows:

[ [email protected] ~]#Find $home – name “. *” – LS # has been queried recursively

The output is as follows:

Copy code

The code is as follows:

553607 4 -rw-r–r– 1 root root 100 Sep 22 2004 ./.cshrc
6553664 4 -rw——- 1 root root 1024 Nov 17 04:40 ./.rnd
6553604 4 -rw-r–r– 1 root root 18 May 20 2009 ./.bash_logout
6553665 4 drwx—— 2 root root 4096 Dec 18 2012 ./.gnupg
6553671 0 -rw——- 1 root root 0 Dec 18 2012 ./.gnupg/secring.gpg
6553669 0 -rw——- 1 root root 0 Dec 18 2012 ./.gnupg/pubring.gpg~
6553673 4 -rw——- 1 root root 899 Dec 18 2012 ./.gnupg/pubring.gpg
6553667 8 -rw——- 1 root root 7856 Dec 18 2012 ./.gnupg/gpg.conf
6553668 4 -rw——- 1 root root 1200 Dec 18 2012 ./.gnupg/trustdb.gpg
6553602 20 -rw——- 1 root root 17462 Apr 7 10:55 ./.bash_history
6553610 4 drwx—— 3 root root 4096 Jan 16 2013 ./.config
6553660 4 drwx—— 2 root root 4096 Jan 16 2013 ./.config/htop
6553681 4 -rw-r–r– 1 root root 597 Apr 11 2013 ./.config/htop/htoprc
6553723 12 -rw——- 1 root root 9629 Mar 30 23:56 ./.viminfo
6553615 4 drwxr-xr-x 3 root root 4096 Nov 29 2012 ./.original-configs

To store the results in the text file foo.txt, use the output redirection command as follows:

Copy code

The code is as follows:

[[email protected] ~]#find $HOME -name “.*” -ls > foo.txt
[ [email protected] ~]#Cat foo.txt # view the contents of the foo.txt file, that is, the result of the find command

Let’s say I want to view / home / www/   Hide files and folders under and save the results to foo.txt. Use the following command:

Copy code

The code is as follows:

[[email protected] ~]#find /home/www/ -name “.*” -ls > foo.txt

Recommended Today

Apache sqoop

Source: dark horse big data 1.png From the standpoint of Apache, data flow can be divided into data import and export: Import: data import. RDBMS—–>Hadoop Export: data export. Hadoop—->RDBMS 1.2 sqoop installation The prerequisite for installing sqoop is that you already have a Java and Hadoop environment. Latest stable version: 1.4.6 Download the sqoop installation […]