I would like to find the directory which keeps a certain file and cd there. e.g.
find * -name hello.txt
output: Documents/Projects/hello.txt
cd Documents/Projects
How do I pipe these commands? Thanks!
|
I would like to find the directory which keeps a certain file and cd there. e.g.
output: Documents/Projects/hello.txt
How do I pipe these commands? Thanks!
| |||||||
feedback
|
|
Try
or
You'll need to provide a EDIT and if you have spaces in your filenames
and if you have spaces in your directory names too
| |||||||||||
feedback
|
|
Instead of finding all and
| ||||
|
feedback
|
|
solution 1 find * -name hello.txt | xargs dirname solution 2 find . -type d -print | |||
feedback
|