bash - example parameters for "find"
A list with examplary parameters of how to use the terminal function "find" (in Linux). This function can be used to find files, directories, etc. First open the terminal (Ctrl+Alt+t) and then type in one of the following commands.
COMMAND | DESCRIPTION |
find /path/where/to/find -name "my_img.png" |
find the file called "my_img.png" (in all sub-directories) (case-sensitive) |
find / -iname "file_name" |
find (search through all files) by case-insensitive name |
find / -not -name "file_name_to_avoid" |
find all files but (regexp can be used) |
find / -type TYPE |
find by type (find -type f OR find -type d) f= file, d=directory |
find / -type f -iname "*.png" |
find all *.png or *.PNG images of type file |
find / -size -10M |
find files less than 10MB (+10MB would be more than 10MB) |
find / -mtime -1 |
find files with modification time less than 1 day ago |
find / -atime +2.3 |
find files with access time more than 2.3 days ago |
find / -mmin -0.2 |
find files modified within the last 0.2 minutes |
find / -perm 644 |
find with these exact permissions |
find / -perm -644 |
find files with at least these permissions |
find . -perm 644 -exec chmod 664 {} \; |
find files and execute a command (here change permission) |
find -mmin -5 -exec rename 's/Chse/Cheese/' {} \; |
find files modified within the last 5 minutes and rename the part Chse of each file to Cheese (executes rename command once for every file) |
find -mmin -5 | xargs -i cp {} ~/Desktop/ |
find files modified within the last 5 minutes and copy them to the desktop (xargs normally operates on all found files, -i specifies that operation is once for every file) |
find . -name "*.txt" -exec sed -i "s/badOld/goodNew/g" '{}' \; |
replace all occurences of the word badOld to goodNew in all *.txt files in the current folder |
|
|
Add new comment