Finding a File by Its Size

In the previous examples, you used the find command to search for a file based on a specified location and to find a file based on its creation date. Both are good examples of searching for a good reason—you don't know where the file is! But why would you search for a file by its size? It may be easy to remember a name or when you worked on a file, but its size?

Believe it or not, there will be many times when you need to search a system for a file by its size. One great example is if you are a web designer and have large graphics files on your Unix system. Here, it's a great bet that these files will be larger than your word processor documents or spreadsheets.

To search by size, use the following steps:

1.
Select a target file size, and find will locate all files of the selected size and larger.

2.
Choose a starting directory.

3.
Start the find program using the -size option: find <starting directory> -size <k> -print.

For example:

>find ~/ -size 1024k -print
/home/rob/updates/testgraphic.jpg

The find command you see here has located a graphics file that is larger than 1,024k.

What Else Can You Find? The find command is powerful. As you can see, using the find command with the -name, -ctime, and -size options can be helpful, but believe it or not, there is more.

Remember, with Unix, the power is at the command line. Use the man pages (as discussed in Lesson 2, “Getting Help”) to learn other helpful options.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.28.202