The Command That Humbles Us All

By Chris Josephes
May 11, 2009 | Comments: 1

Every systems administrator faces an unavoidable truth. It's something that puts everyone in the field on equal footing; and each one of us will be confronted by this truth at least once in our careers.

No matter how good you are, someone else is better than you with the find command.

With that said, here's a quick way to grab the filename and size of every file on a Netapp mount, avoiding the .snapshot directories. This method only works with the GNU version of find.

find . -name ".snapshot" -prune -o -printf "%p:%s\n"

If you're expecting thousands of lines of output, don't forget to pipe your output to the split command.

Chris Gerhard also posted a find invocation that prevents searching through remote filesystems.

And for the beginners, here's a link to the Find Tutorial.

Show off your find skills. Post your favorite use here.


You might also be interested in:

1 Comment

If most of your work with find is finding files of a certain type, such as finding Perl files,

find . -name '*.pl' -o -name '*.pm'

you may want to look at ack and the ack -f option.

ack -f --perl

Much easier to type, and it also checks shebang lines to determine filetypes if the file has no extension. It's optimized for programmers.

http://betterthangrep.com/

News Topics

Recommended for You

Got a Question?