Description#
finds files or directories by name.
Usage#
# Search file in root directory with name test.txt
find / -name "test.txt"
# search all the files ending with txt extension and getting its long listing
find . -maxdepth 1 -name "*.txt" -exec ls -l {} \\;
# all files in home directory with size > 1MB
find ~ -type f -size +1M
Options#
| Options | Description |
|---|
| -name | name of the file or directory to search |
| -mindepth | start searching after certain depth |
| -maxdepth | limit search to certain depth |
| -exec | execute a command for each file found |
| -perm | search for file with specific permission |
| -group | search files owned by specific group |
| -user | search files owned by specific user |
| -type | f for files, d for directories, l for symbolic links |
| -size | size of the file or dir |
Installation#
| Distro/OS/Package Manager | Install Instruction |
|---|
| Centos/fedora(dnf, microdnf, rpm, yum) | yum install findutils |
| Debian/ubuntu | apt install findutils |
| Arch (pacman) | pacman -Sy findutils |
| Alpine (apk-docker) | apk add findutils |
References#