Find Commands: Difference between revisions

From Cramsession
Jump to navigationJump to search
✍️ Verified Author: MflavellClick to view professional profile & credentials
No edit summary
No edit summary
Line 17: Line 17:


  find . -type f -name "name_*"
  find . -type f -name "name_*"
= File delete using Find =
Delete all files more than ''M'' days in current folder
find . -type f -mtime +''M'' -exec rm {} \;

Revision as of 22:21, 12 November 2024

Files in current folder modified today

find . -mtime -1 -type f

if you just want the filename:

find . -mtime -1 -type f printf "%f\n"

-1 can be changed to another value to go back further


Recursive find

find . -iname "fidnme*"

Find a file that starts with name_

find . -type f -name "name_*"

File delete using Find

Delete all files more than M days in current folder

find . -type f -mtime +M -exec rm {} \;