CHAPTER9

Finding Large Files and Files of a Specific Type

Filesystem alert! We all hate to get full-filesystem alerts, especially at quitting time on Friday when the developers are trying to meet a deadline. The usual culprit is one or more large files that were just created, compiled, or loaded. Determining the definition of a large file varies by system environment, but a “large” file can fill up a filesystem quickly, especially in a large database or development environment. To find the files that quickly fill up a filesystem and/or other large files, we need a flexible tool that will search for files larger than a user-defined value. The find command is your friend when a filesystem search is needed.

The find command is one of the most flexible and powerful commands on the system. Before we get started, I want you to have a copy of the find command manual page. You have two options to save a copy of the man page for the find command. The first option uses paper (you know, in a printer), and the second option saves a bunch of trees. To send the manual page for the find command to a specific print queue (in other words, burn up some trees), enter the following command:

man find | lp -d print_queue_name

If you are interested in saving the planet, you can archive the find command manual page by executing the following command:

man find | col -b >> find.txt

The previous command will print the manual page output to the printer defined by print_queue_name, or save the manual page ...

Get Mastering UNIX® Shell Scripting: Bash, Bourne, and Korn Shell Scripting for Programmers, System Administrators, and UNIX Gurus, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.