Quantcast
Channel: find and remove files bigger than a specific size and type - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 4

Answer by Sundeep for find and remove files bigger than a specific size and type

$
0
0
find -type f \( -name "*zip" -o -name "*tar" -o -name "*gz" \) -size +1M -delete
  • the \( \) construct allows to group different filename patterns
  • by using -delete option, we can avoid piping and troubles with xargs See this, this and this
  • ./ or . is optional when using find command for current directory


Edit: As Eric Renouf notes, if your version of find doesn't support the -delete option, use the -exec option

find -type f \( -name "*zip" -o -name "*tar" -o -name "*gz" \) -size +1M -exec rm {} +

where all the files filtered by find command is passed to rm command


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>