Linux find file by extension
To search all *.js files containing the string 'example', type: find. If you want to find the file containing a specific string you can combine find and grep together. For example to find text files that were last modified 60 days ago, type: find /home/username -name "*.txt" -mtime -60 Find File containing specific string To search file or files under a directory by the last modified, use -mtime option. To find empty file or files, you use file type -empty.įor example to find all empty files in /tmp directory, type: find /tmp -type f -empty Find a File by modification time For example to search file (or files) with an extension ".txt", type: find /home/bob -name "*.txt" Find an empty file Use find command to find a file (or files) using file extensions.
To perform a case-insensitive search, use -iname option instead of -name: find /home/bob -iname File2.txt Find files in Linux by extension To search the file named file2.txt in the directory path /home/bob and its subdirectories. For example to search the file named file1.txt in the current directory and subdirectories. You can use find command to find a file by name. The -name "*.conf" (expression) tells find command what to search for.The /etc (starting-point) specifies the directory from where to start seaching.The -L (options) tells find command to follow symbolic links.The option -03 (options) tells to perform an efficient search to give better performance.Options - This controls the treatment of symbolic links, debug options, and performance optimization.įor example: find -O3 -L /etc -name "*.conf" If no paths are given, the current directory is used. ) or directory path where to begin filtering. Starting-point -This can be the current directory (indicate by. The syntax of find command to find a file in Linux: find starting-point options expression
Linux find file by extension how to#
In this tutorial, we learn how to find a file in Linux using the command line. By default, it searches into subdirectories for a file (or files) based on certain conditions.
Linux comes with a powerful tool named find to find a file (or files).