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.
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.
The find command is recursive by default.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With