Find: Difference between revisions
no edit summary
No edit summary |
|||
Line 4:
= General Usage =
Find Text Files
find ~
Find empty folders
find ~
Find all empty files (zero byte file)
Line 20 ⟶ 21:
find . -maxdepth 1 -empty -not -name ".*"
find -name "MyCProgram.c"▼
Find Files Using Name and Ignoring Case
find -iname "MyCProgram.c"
Find the passwd file under root and one level down
find -maxdepth 2 -name passwd
Find all directories
Line 49 ⟶ 41:
find -type d -name ".*"
List and Export only files recursively without Directory name▼
find . -maxdepth 10 -type f -printf '%f\n' > fileslist.txt▼
= Time based Sort =
Line 86 ⟶ 77:
find -mmin -60 -exec ls -l {} \;
Restricting the find output only to files▼
find /etc/sysconfig -amin -30 -type f▼
Do not display hidden files in find output▼
find . -mmin -15 \( ! -regex ".*/\..*" \)▼
= Delete Files =
Line 107 ⟶ 103:
Move Specific files to another location
find ./* -name *.jpg -exec mv {} ~/Public/ \;
Search all jpg images in the system and archive it▼
find ~/test -name *.jpg -type f -print | xargs tar -cvzf images.tar.gz▼
Inverting the match▼
Line 146 ⟶ 130:
find / -type f -name *.zip -size +100M -exec rm -i {} \;"
▲Restricting the find output only to files
▲ find /etc/sysconfig -amin -30 -type f
▲Do not display hidden files in find output
▲ find . -mmin -15 \( ! -regex ".*/\..*" \)
If you don’t want to see the errors and would like to redirect it to null▼
find -name "*.txt" 2>>/dev/null▼
Line 195 ⟶ 163:
Executing Commands on the Files Found by the Find Command
find -iname "MyCProgram.c" -exec md5sum {} \;
= Advanced Options =
▲List and Export only files recursively without Directory name
▲ find . -maxdepth 10 -type f -printf '%f\n' > fileslist.txt
▲If you don’t want to see the errors and would like to redirect it to null
▲ find -name "*.txt" 2>>/dev/null
▲Search all jpg images in the system and archive it
▲ find ~/test -name *.jpg -type f -print | xargs tar -cvzf images.tar.gz
▲Inverting the match
<br />
|