For example, if you search your entire filesystem for the files named home.jpg: find / -name home.jpg More likely than not. The find command requires the path to the directory you want to search in, options to specify what attribute youre searching (for instance, - name for a case-sensitive file name), and then the search string. Depending on the size of your file system and the depth of your search, the find command can sometime take a long time to scan all of the data. You can locate a file by its filename by providing the full file name or parts of the file name using regular expressions. It also provides various options to do the selective search. $ ls -d you want to include subdirectories, you can enable the globstar option as well and add a ** wildcard i.e. You can provide multiple options to the find command, so let us look at them. Two popular commands for locating files on linux are find and locate. The find command in Linux provides an easy way to search files recursively in a directory hierarchy. */ as well, before the 5 character filenameĪlternatively, for a pure bash solution, you could enable extended shell globbing and then use the pattern meaning 'anything that does not match one or two or three or four characters' $ shopt -s extglob Note that -regex is a path match rather than a file match - hence you need to match the leading. You could use the find command with a -regex test $ find /path/to/folder -regextype posix-basic -regex '.*/.\'
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |