— < 1 min read

I needed to quickly modify 500 hundred XML files, each was about 10MB in size, thankfully Linux makes that pretty fast and very easy.

find . -name "*.xml" -print | xargs sed -i 's/FROM/TO/g'

A semi “real world” example:

find . -name "*.xml" -print | xargs sed -i 's/foo/bar/g'
 — < 1 min read

This is a really great simple way to find files on the filesystem that are over 200k in size.

find /path/to/directory/ -type f -size +200k -exec ls -lh {} ; | awk '{ print $NF ": " $5 }'

You can use the output of this to either store in a file, or pipe to wc for a count of lines

find /path/to/directory/ -type f -size +200k -exec ls -lh {} ; | awk '{ print $NF ": " $5 }' | wc -l

You can also use egrep before wc to look for specific filetypes

find /path/to/directory/ -type f -size +200k -exec ls -lh {} ; | awk '{ print $NF ": " $5 }' | egrep '(jpg|bmp|gif|tiff|jpeg)' | wc -l