Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a bash script /var/www/scripts/process_sounds.sh that uses the command:

find /var/www/unprocessed_sounds/ * -type f

It's supposed to find all the files in the unprocessed_sounds directory, which it does, but it also find all the files in the scripts directory (and then processes them like sound files, which is not what I want).

Why would find return things in the current directory?

share|improve this question
1  
Incidentally, if you actually wanted a wildcard match for something, you could do -name '*', but it only would make sense if it were something other than *. –  Random832 Nov 3 '12 at 22:45
add comment

3 Answers

up vote 6 down vote accepted

You are writing the command in the wrong way. To search for file in /var/www/unprocessed_sounds/ directory, you should just write like this

find /var/www/unprocessed_sounds/ -type f

Writing like find /var/www/unprocessed_sounds/ * -type f will search for file in /var/www/unprocessed_sounds/ and * which means all directories in current directory also.

share|improve this answer
add comment

you have a space in your command

find /var/www/unprocessed_sounds/ * -type f

find is interpreting that you want to look for all files in /var/www/unprocessed_sounds/ AND ./* take the star away (as find will dig into the directory anyway)

share|improve this answer
add comment

If you only want to process the files in the /var/www/unprocessed_sounds/ directory, then you don't need to use the * in there.

Try to only use:

find /var/www/unprocessed_sounds/ -type f
share|improve this answer
add comment

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.