I want to clean up my server from large log files and backups.
I came up with this:
find ./ -size +1M | xargs rm
But I do not want to include mp3 and mp4. I just want to do this for log and archive files (zip, tar, etc.)
How will the command look like?
Best Answer
\( \)
construct allows to group different filename patterns-delete
option, we can avoid piping and troubles withxargs
See this, this and this./
or.
is optional when usingfind
command for current directoryEdit: As Eric Renouf notes, if your version of
find
doesn't support the-delete
option, use the-exec
optionfind -type f \( -name "*zip" -o -name "*tar" -o -name "*gz" \) -size +1M -exec rm {} +
where all the files filtered by
find
command is passed torm
command