cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

os:linux:command:find.html



Linux Commands#File, Directory

find - How to use find command in Linux with examples

search for files in a directory hierarchy



Use frequently

Operation Commands
delete files before 7 days find /testdir -type f -name "*test*" -mtime +6 -exec rm -rf {} \;
find recently change files find /testdir -mtime -5 -ls

Count

Operation Commands
count file find DIR -type f | wc -l
count directory find DIR -type d | wc -l
count file and directory find DIR -name \* | wc -l

Tips

Operation Commands
delete so many files find /path -type f | xargs -n 10 rm
move so many files find . -maxdepth 1 -name "*.txt" |xargs mv -t tmp/
delete the file incluce space in name find /path -type f -print0 | xargs -0 rm
compress many files find . -type f |xargs tar rvf test.tar
You must not use “cf” but “rf”.



os/linux/command/find.html.txt · Last modified: 2020/02/07 by admin

Page Tools