Loading…
Warp is now open-source Learn more
Loading…
In Unix-like operating systems such as Linux and macOS, to find all the regular files that match a specified pattern, you can use the find command as follows:
$ find <directory …> -type f -name "<pattern>"Where:
For example, this command will list all the files with a .pdf file extension located in the ~/Downloads directory and its subdirectories:
$ find ~/Downloads -type f -name "*.pdf"And this command will list all the files named package.json located in both the app and api directories:
$ find app api -type f -name "package.json"If you’re using Warp as your terminal, you can easily retrieve this command using the Warp AI Command Suggestions feature:

Entering the linux find file into the AI Command Suggestions will prompt a find command that can then be quickly inserted into your shell by doing CMD+ENTER.
By default, the find command will perform a recursive search in all the subdirectories of the specified directory.
To limit the search to a specific depth, you can use the -maxdepth flag as follows:
$ find <directory> -maxdepth <depth> -type f -name "<pattern>"Where:
For example, this command will list all the files with a .js file extension located in the app directory only:
$ find ./app -maxdepth 1 -type f -name "*.js"The find command offers a multitude of flags for finding and filtering files based on various properties such as their size, type, owner, and more.
Here is a shortlist of the most popular ones.
To find files based on their type, you can use the -type flag as follows:
$ find <directory> -type <type>Where:
For example, this command will recursively list all the regular files with a .log file extension located in the current working directory:
$ find . -type f -name "*.log"To find files based on their size, you can use the -size flag as follows:
$ find <directory> -size <size>Where:
For example, this command will list all the regular files located in the current working directory with a size of about 20 megabytes:
$ find . -type f -size 20MAdditionally, you can prefix the <size> parameter with the minus character (-) to search for files with a lesser size:
$ find . -type f -size -20MOr with the plus character (+) to search for files with a greater size:
$ find . -type f -size +20MTo find files based on their owner, you can use the -user flag as follows:
$ find <directory> -user <user>Where:
For example, this command will list all the files owned by the user named durojaye located in the ~/shared directory:
$ find ~/shared -user durojayeTo find files based on their group, you can use the -group flag as follows:
$ find <directory> -group <group>Where:
For example, this command will list all the files owned by the group named developers located in the /bin directory:
$ find /bin -group developersTo find files based on their latest modification date relative to a reference file, you can use the -newer flag as follows:
$ find <directory> -newer <reference>Where:
For example, this command will list all the regular files that were modified after the backup.tar.gz file located in the current working directory:
$ find . -type f -newer backup.tar.gzTo find files based on their contents, you can perform a pattern search using the grep command through the find command using the -exec flag as follows:
$ find <directory> -type f -exec grep -l '<pattern>' {} +Where:
For example, this command will list all the regular files that contain the word network located in the /etc directory:
$ find /etc -type f -exec grep -l 'network' {} +Comments will help make your scripts more readable
Via command line arguments and prompting users for input
Use cURL to send data to a server
Learn how to upload a file to FTP, SFTP servers, Artifactory, and AWS S3 using the curl command.
Learn how to copy directories and their content in Linux using the cp command with options like -r for recursive copying, -i for interactive mode, and -a for preserving attributes.
Learn how to manually and automatically create and list groups in Linux.
Learn how to output the size of directories and subdirectories in a human-readable format in Linux and macOS using the du command.
Learn how to count files and folders contained in directories and subdirectories in Linux using the ls, find, and wc commands.
Learn how to output the list of open TCP and UDP ports in Linux, as well as their IP addresses and ports using the netstat command.
Learn how to filter and format the content of files and the output of commands in Linux using the awk command.
Learn how to recursively create nested directories using the mkdir command, Bash scripts, and Python scripts.
Learn how to remove local and remote user accounts and associated groups and files in Linux using the userdel and deluser commands.
$ find <directory …> -type f -name "<pattern>"$ find ~/Downloads -type f -name "*.pdf"$ find app api -type f -name "package.json"$ find <directory> -maxdepth <depth> -type f -name "<pattern>"$ find ./app -maxdepth 1 -type f -name "*.js"$ find <directory> -type <type>$ find . -type f -name "*.log"$ find <directory> -size <size>$ find . -type f -size 20M$ find . -type f -size -20M$ find . -type f -size +20M$ find <directory> -user <user>$ find ~/shared -user durojaye$ find <directory> -group <group>$ find /bin -group developers$ find <directory> -newer <reference>$ find . -type f -newer backup.tar.gz$ find <directory> -type f -exec grep -l '<pattern>' {} +$ find /etc -type f -exec grep -l 'network' {} +