UNIX Find A File Command

‮:sptth‬//www.lautturi.com
UNIX Find A File Command

To find a file on a Unix-like system, you can use the find command. The find command can search for files based on various criteria, such as name, type, size, and permissions.

For example, to find a file named myfile.txt in the current directory and its subdirectories, you can use the following command:

find . -name myfile.txt

This will search for files named myfile.txt in the current directory and its subdirectories, and display the path to each file found.

You can also use the -iname option to perform a case-insensitive search. For example:

find . -iname myfile.txt

This will search for files named myfile.txt (regardless of case) in the current directory and its subdirectories, and display the path to each file found.

To search for files of a specific type, you can use the -type option followed by the type of file you want to search for. For example, to search for regular files, you can use the f option:

find . -type f -name myfile.txt

This will search for regular files named myfile.txt in the current directory and its subdirectories, and display the path to each file found.

You can also use the -path option to search for files based on their path. For example, to find a file named myfile.txt in the /home/user/documents directory, you can use the following command:

find /home/user/documents -name myfile.txt

This will search for files named myfile.txt in the /home/user/documents directory, and display the path to each file found.

You can find more information about the find command and its options in the find documentation or by running the find --help command.

Created Time:2017-10-30 14:27:22  Author:lautturi