Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find does not find recursively [closed]

Tags:

linux

find

shell

I'm in directory "home" and I run this command

find . -iname *.mov

and it produces

./root/movies/Corey/holtorf/Intro.mov

Now, I "cd .." and run the same command

find . -iname *.mov

This time "Intro.mov" is not in the result. What are the reasoning behind this? And what is the command to search recursively for every file ending with ".mov" in the current directory? Thanks.

like image 317
Sean Xiao Avatar asked Apr 10 '13 16:04

Sean Xiao


People also ask

Does find command work recursively?

Use the find command to recursively search the directory tree for each specified Path, seeking files that match a Boolean expression written using the terms given in the following text.

Is find recursive by default?

The find command is recursive by default.

How do I run find command recursively?

The find command does not need flags to search the files recursively in the current directory. You only need to define the main directory and the file name using the –name option. This command will search the file within the main directory and all subdirectories.

How do I find files recursively?

Using the find Command and the -exec <command> {} + Option. The find command can find files recursively under a given directory. Moreover, it provides an option “-exec <command> {} +” to execute a command on all found files.


1 Answers

When using a wildcard in an argument it is expanded by the shell. To prevent this, you need to write "*.mov".

In your case, the shell expands to whatever files it finds before passing the argument to find, which then gets a list of files and will not search based on the original pattern.

like image 70
ypnos Avatar answered Sep 27 '22 21:09

ypnos