cnewer file File's status was last changed more recently than file was modified. If file is a symbolic link and the -H option or the -L option is in effect, the status-change time of the file it points to is always used. The (expression) -name "*.js tells find to search files ending with.The /var/take a look at the following example: find -L /var/The expression attribute is made up of options, search patterns, and actions separated by operators.attribute defines the starting directory or directories where find will search the files. To run a case-insensitive search, change the -name option with -iname: find /home/linuxize -type f -iname document.pdf To find a file by its name, use the -name option followed by the name of the file you are searching for.įor example, to search for a file named document.pdf in the /home/linuxize directory, you would use the following command: find /home/linuxize -type f -name document.pdf js (JavaScript files).įinding files by name is probably the most common use of the find command. The command above will match “Document.pdf”, “DOCUMENT.pdf”. Searching for files by extension is the same as searching for files by name. log.gz inside the /var/log/nginx directory, you would type: find /var/log/nginx -type f -name '*.log.gz' For example, to find all files ending with. It is important to mention that you must either quote the pattern or escape the asterisk * symbol with backslash \ so that it doesn’t get interpreted by the shell when you use the wildcard character. The common example would be to recursively change the website file permissions to 644 and directory permissions to 755 using the chmodĬommand: find /var/you would use: find /var/log/nginx -type f -not -name '*.log.gz' Find Files by Type # To find all files that don’t match the regex *.log.gz you can use the -not option. To delete all matching files, append the -delete option to the end of the match expression.Įnsure you are using this option only when you are confident that the result matches the files you want to delete. It is always a good idea to print the matched files before using the -delete option.įor example, to delete all files ending with. Temp from the /var/log/, you would use: find /var/log/ -name `*.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |