8/16/2023 0 Comments Command line find file type linuxTo 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 |