2

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?

  • 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
6

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.

2

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)

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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