当前位置: 技术问答>linux和unix
如何用shell命令一次将查找的文件打开?
来源: 互联网 发布时间:2015-04-20
本文导语: 也就是有两个动作: 1)查找所需文件 2)将找到的文件打开,(显示也行) 用一条shell语句实现! | find . -name "*.c" | xargs cat 或者是 find . -name "*.c" | while read f; do cat $f; done | ...
也就是有两个动作:
1)查找所需文件
2)将找到的文件打开,(显示也行)
用一条shell语句实现!
1)查找所需文件
2)将找到的文件打开,(显示也行)
用一条shell语句实现!
|
find . -name "*.c" | xargs cat
或者是
find . -name "*.c" | while read f; do cat $f; done
或者是
find . -name "*.c" | while read f; do cat $f; done
|
cat `find ./ -name "*.c" -print`
find ./ -name "*.c" will find all of the file ended with .c,
and the option -print let the find output the full file name, which it finded.
(e.g. ./work/hello.c)
After the command find, the result will pass to cat.
So the cat can show all content of the found file^
find ./ -name "*.c" will find all of the file ended with .c,
and the option -print let the find output the full file name, which it finded.
(e.g. ./work/hello.c)
After the command find, the result will pass to cat.
So the cat can show all content of the found file^
|
或者
cat `find ./ -name "*.c" -print`
注意: ` 即键盘左上角的~
cat `find ./ -name "*.c" -print`
注意: ` 即键盘左上角的~
|
find / -name "*.c" -print -exec cat { }
有点忘了字符串是 打 单引号/双引号/不打引号?!
'字符串'/"字符串"/字符串?!
有点忘了字符串是 打 单引号/双引号/不打引号?!
'字符串'/"字符串"/字符串?!
|
一般来说,
具体的字符串 双引号 "helloworld"
含有通配符的字符串 单引号 'hell?worl?'
具体的字符串 双引号 "helloworld"
含有通配符的字符串 单引号 'hell?worl?'