简体   繁体   中英

Creating a file with a list of paths (nested directories)

I have a set of nested directories in a tree-like structure, and every directory at the bottom of the tree contains another directory called "dump".

I would like to create a file called "paths" with the all the paths to the "dump" directories, each one separated by a new line.

My attempt is:

echo ./*/*/*/dump | cat >paths

This kind of works, but the paths are not separated by a new line. How can I achieve this, possibly using echo and cat?

echo与glob一起使用,并将其一次通过管道传送到xargs-n1 )并将其写入文件为

echo ./*/*/*/dump | xargs -n1 > file

You can use find instead:

find . -type d -path '*/dump' > paths

or else just replace echo by printf in your glob :

printf "%s\n" ./*/*/*/dump >paths

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM