Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have twenty directories and im looking for a file with a known length somewhere in one of the directories.

Is there a Linux command to search a directory for a file by size?

What is the best method to locate this file?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

The standard command to find files is find:-

find {directory} -size {byte count}c

If the directories are in disparate places, you can either use a for command to search each of the directories in turn, or create a specific directory with links (preferably hard links) to each of the directories, then find within that master directory.

share|improve this answer
    
(My answer crossed with choroba's, but I am leaving it in because of the extra information I gave about multiple directories.) –  AFH Jul 24 at 17:44
    
This was perfect. I love you. –  Nebur Jul 24 at 22:56

Use find and its -size option:

find -size NNNc

c means the size in bytes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.