Reputation: 21
Could someone please give me the command to delete log files before today (except today and yesterday) date?
Upvotes: 2
Views: 5533
Reputation: 881323
You can use find
with the -mtime
option to get a list of files modified more than N
days ago.
For example:
find . -maxdepth 1 -name '*.txt' -mtime +2
will give you all the *.txt
files in the current directory older than 48 hours.
You can add -delete
to actually get rid of them.
Upvotes: 3