find is a very versatile tool. It can do a lot more than just hunt for files.
If you’re new to find, checkout my post How To Use The GNU - Linux Find Command
Here’s some examples of its features that come in handy for everyday usage.
Looking for a file in the current directory
The first argument is the root directory and find is recursive by default, so this will return a list of all files in the current directory and any of its subdirectories with the name “my_file.txt”.
Looking for all png files in an folder:
If you have a filesystem based cache, it can be really handy to just purge the files that haven’t been used for a while.
All files that haven’t been touched for at least 7 days:
Sometimes you need to purge the cache but you only care about binning the PNGs.
Delete all pngs that haven’t been accessed in the last month
If you’re running out of space, hunting down large files from the command line can be a pain, but not with find.
Files in your home directory that are larger than 500MB
Some units that are common for the -size argument:
c : Bytes
k : Kilobytes
M : Megabytes
G : Gigabytes
Mac and Windows litter the file systems with metadata files. This might be fine in a fully homogeneous environment, but when you have may different OSs sharing network storage, these .DS_Store and Thumbs.db files can be an unsightly mess.
To remove Mac OS X and Windows messy files you could use:
Tags: LinuxPosted on 05 May 2013. blog comments powered by Disqus
Monitoring frequency drift on the RTL SDR dongle
High entropy passwords are serious business! Here some little helpers to create better ones.
Running Linux and need to look busy quick? Try this little bit of command line fun :)
Bash scripts and command line examples are often littered with ampersands. Here's what they do.
Some handy tricks for killing Linux processes from the command line.