开发者

In Unix,cmd to search a file recursively and retrieve the file instead of just the path of the file

开发者 https://www.devze.com 2023-01-27 14:47 出处:网络
In Unix, what is the single cmd that lets me search and locate a file recursively and then retrieve the file instead of just the pa开发者_运维问答th of the file?What do you mean by retrieve?

In Unix, what is the single cmd that lets me search and locate a file recursively and then retrieve the file instead of just the pa开发者_运维问答th of the file?


What do you mean by retrieve?

You can simply use -exec argument to find.

$ find /path/to/search -type f -name '*.txt' -exec cat {} \;
$ find /path/to/search -type f -name 'pattern' -exec cp {} /path/to/new \;

The second one should work.


cat `find /wherever/you/want/to/start/from -name name_of_file`

Note those quotes are backquotes (`).

0

精彩评论

暂无评论...
验证码 换一张
取 消