![]() ![]() Case-sensitive search: find /path/to/directory -name 'filename.txt'.To search for files by their name or pattern, use the -name option followed by the file name or pattern enclosed in single quotes. -group: Search for files based on their group.-user: Search for files based on their owner.-mtime: Search for files based on their modification time.-size: Search for files based on their size.-type: Search for files based on their type (e.g., regular files, directories, symbolic links).-name: Search for files based on their name or pattern.EXPRESSION: The search criteria, including options and tests.PATH: The directory in which to start the search.Use the -user flag to get files that belong to a particular user. find /home - type f -perm /777 Find Files by Owner Use the forward-slash character ( /) to list the file if at least one category has correct the set of permissions provided. The -perm option allows users to search for files with a particular set of permissions. find /home - type f -name "*.txt" -mtime +5 Search for Files With Specific Permissions You can also use the plus and minus signs to find files greater than or smaller than a specific timestamp. Similarly, you can also use -atime and -ctime to filter the files according to the access time and change time. The above-mentioned command will print all the files that were modified in the last five days. To find files with a particular modification time: find /home - type f -name "*.txt" -mtime 5 These timestamps contain the modification time, change time, and access time. You might already know that Linux assigns specific timestamps to each and every file on your storage. To search for files within a size range: find /home - type f -size +1M -size -10M Find Files Using Timestamps Similarly, use the plus ( +) operator to locate files that are greater than 1GB: find /home - type f -size +1G To search for files less than 1GB, add the minus ( -) character before specifying the size: find /home - type f -size -1G To find all the files that have a file size of 1GB: The following suffixes denote the various file sizes: The -size flag allows you to search for files that take up a particular amount of space on the disk. To search for sub-directories present in the /home directory: find /home - type d Find Files by Size To search for other file types in Linux, replace f with other reserved characters. Till now, we have been using the -type f option in the find command. Directories, symbolic links, sockets, and character devices are some of the file types that are supported by find. In addition to files, the find command can search for other type of files as well. This command will search for all PDF files in the /home directory and change their permissions so that anyone can read, write, and execute those files. For example, to change the moderation permissions for each file that fits the condition:įind /home - type f "*.pdf" - exec chmod -777 \ You can even pipe the find command with other Linux commands. The following command will search for files that do not have the. You can also inverse the above command by using the -not flag. Note that you will have to escape the asterisk ( *) character with either quotes ( "") or a backward slash ( \) so that the terminal interprets it as a wildcard character. This command will display a list of all the files that have the. To find a file by its extension, use the following regular expression with the -name and -iname flag. Searching for files with a particular extension can help in narrowing down your search results. Similarly, / for /root and ~ for /home can be used as well. ![]() (period) to specify the relative path of the current directory as well. ![]() Like any other Linux command, you can use. This command will locate a file that has either of the following names: Filename, filename, FileName, FiLename, etc. If you want to ignore the character case in the file name, replace the -name option with -iname. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |