AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Command line find file controller10/11/2023 The find Linux command only filters files based on filenames and metadata. find -O3 /path -name "*.html" Searches based on content: Find + Grep – O3 enables find to automatically reorder filters to prioritize efficiency and likelihood of success. find -O2 /path -name "*.html" -O3: efficiency and likelihood of success O2 enables find to filter by filename and type of file before running more demanding filters. find -O1 /path -name "*.html" -O2: filename and type of file It enables find to start filtering by filename before running any other test. There are three stages of optimization for enhancing filtering when using the find Linux command. Placed between two conditions to indicate that it is necessary to ignore the second condition. Placed between two conditions to indicate that it is necessary to filter by at least one of the conditions. Placed between two conditions to indicate that it is necessary to include both conditions. Limiting the search to a given amount of sub-directories. Making a case insensitive search by name to locate a file.įiltering files limiting the period of time of its modification. Since the find command ignores symbolic links by default, add the -L option to the command to follow and show them: find -L /path -name *.html Locating files by file sizeįor finding bigger than 500MB files in a directory and all sub-directories, type the following command into the command line: find /path -size +500M Combining two conditions or filtersįor instance, for filtering files ranging between 500MB and 1GB in a directory and all sub-directories, type the following command into the command line: find /path -size +500M -and -size -1G Filtering by at least one of the specified conditionsįor instance, for filtering files by one of the indicated extensions in a directory and all sub-directories, type the following command into the command line: find /path -name *.docx -or -name *.odt Excluding the second conditionįor instance, for excluding an extension from a search in a directory and all sub-directories, type the following command into the command line: find /path -name *.docx -not -name *.odt Option or search parameter name filename.html Locating files modified during a period of timeįor finding files that have been changed during the previous week, type the following command into the command line: find /path -mtime 7 “.html” Locating files modified during a period of time by a particular userįor finding files that have been changed during the previous week by a particular user, type the following command into the command line: find /path -user username -mtime 7 “.html” Limiting the search to a specific number of sub-directoriesįor limiting the search to a maximum amount of sub-directories, add the -maxdepth X option to the command: find -maxdepth 3 /path -name *.html Ignoring text caseįor making a case insensitive search, add the -iname option to the command: find /path -iname *.html Searching filesįor exclusively searching files, add the -type f option to the command: find /path -type f -name “*.html” Searching directoriesįor exclusively searching directories, add the -type d option to the command: find /path -type d -name “*.html” Following and showing symbolic links expression: it defines the actions to perform to create an output.įind command options Locating files by name in Linuxįor finding files by name in a directory and all sub-directories, type the following command into the command line: find /path -name filename Locating files by extensionįor finding files by extension in a directory and all sub-directories, type the following command into the command line: find /path -name *.html Locating files in the current directoryįor finding files in the current directory, type the following command into the command line: find./path: it defines the top-level directory where the find command will start filtering.-options: options or search parameters enable control of the behavior and optimization method of the find process.The basic syntax of the command is as follows: find -options /path expression Find command attributes The find command is used to locate files in Linux, based on user-specified criteria. 4 Searches based on content: Find + Grep Linux find command
0 Comments
Read More
Leave a Reply. |