Ways to find hidden files in Linux using the Find command

Source: Internet
Author: User
Tags gnupg gpg

We can use the Find command on a Linux or Unix system to query all (all) hidden files

The basic syntax is as follows:

Copy CodeThe code is as follows: [[email protected] ~] #find/To find the article/Piece/clip/-name ". *"-print

Explain:

1. ". *" indicates the name of the file to find. Because Linux/unix's hidden files and folder names are in "." Start with. The * indicates a wildcard, meaning to find all file names and folder names, to "." to start files and folders.
2.-print represents the result of a print lookup. Same as-ls function

Or

Copy CodeThe code is as follows: [[email protected] ~] #find/To find the article/Piece/clip/-name ". *"-ls

Or just search for hidden files:

Copy CodeThe code is as follows: [[email protected] ~] #find/To find the article/Piece/clip/-type f-iname ". *"-ls

Or just search for hidden folders:

Copy CodeThe code is as follows: [[email protected] ~] #find/To find the article/Piece/clip/-type d-iname ". *"-ls

Explain:
-type: Specifies the type of file to be searched, whether it is a folder or a file, to be used with F or D
F: The meaning of the document, the document in English is file.
D: On behalf of folders, folders in English is directory
-iname: The case is ignored when matching file names are indicated. For example, find "fo*", then "foo", "foo" will match.

Or

Copy CodeThe code is as follows: [[email protected] ~] #find/To find the article/Piece/clip/-path ' */.* '-print</p> <p>[[email protected] ~] #find/To find the article/Piece/clamp /-path ' */.* '-ls


For an explanation of the-path parameter, see another article, "The function of the-path parameter in the Find command (meaning) explanation"

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 see, you know the meaning)

Copy CodeThe code is as follows: [[email protected] ~] #find $HOME-name ". *"-ls #已经递归查询了

The output is as follows:

Copy CodeThe code is as follows:
553607 4-rw-r--r--1 root root (SEP) 2004./.CSHRC
6553664 4-rw-------1 root root 04:40./.rnd
6553604 4-rw-r--r--1 root root./.bash_logout
6553665 4 drwx------2 root root 4096 Dec/.gnupg
6553671 0-rw-------1 root root 0 Dec./.gnupg/secring.gpg
6553669 0-rw-------1 root root 0 Dec./.gnupg/pubring.gpg~
6553673 4-rw-------1 root root 899 Dec./.gnupg/pubring.gpg
6553667 8-rw-------1 root root 7856 Dec./.gnupg/gpg.conf
6553668 4-rw-------1 root root./.gnupg/trustdb.gpg
6553602 20-rw-------1 root root 17462 Apr 7 10:55./.bash_history
6553610 4 drwx------3 root root 4096 Jan/.config
6553660 4 drwx------2 root root 4096 Jan/.config/htop
6553681 4-rw-r--r--1 root root 597 Apr./.CONFIG/HTOP/HTOPRC
6553723 12-rw-------1 root root 9629 Mar 23:56./.viminfo
6553615 4 drwxr-xr-x 3 root root 4096 Nov/.original-configs

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

Copy CodeThe 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, which is the result of the Find command

The following assumes that I want to view hidden files and folders under/home/www/and save the results to foo.txt. Use the following command:

Copy CodeThe code is as follows:
[[Email protected] ~] #find/home/www/-name ". *-ls > Foo.txt

Ways to find hidden files in Linux using the Find command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.