How do you find all files with a particular parent directory in the linux command terminal?
I know to find all files using find
like so:
find . -name filename.extension
But is it possible to find all filename.extension
files with the parent directory of foldername
?
I have tried the following but this does not work:
find . -name foldername/filename.extension
And I cannot find any example of how to do this.
So some example results I would expect are as so:
./example/project/website/foldername/filename.extension
./folder/demo/foldername/filename.extension
./more/files/foldername/filename.extension
./business/assets/foldername/filename.extension
./steven/foldername/filename.extension
Is there anyway to do this?
Use the ls command to display the contents of a directory. The ls command writes to standard output the contents of each specified Directory or the name of each specified File, along with any other information you ask for with the flags.
You need use the find command. It search for files in a directory hierarchy under Linux and all other UNIX like operating systems. Use find command to find a file from shell prompt when using the Terminal or ssh based session.
Use -path
switch with find
find . -path \*/foldername/filename.extension
Just try this
locate "/*/foldername/filename.extension"
provided you have updated index with updatedb
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