linux查找文件内容


问:   请问ubuntu下面,当前目录中,查找包含相应内容的文件的命令,如在open目录中查找带有“hello”的文件

答:
find ./ | xargs grep -Hn 'hello'



详细例如:

制造对应的目录的几个文件并写些内容:
mkdir open
cd open/
ls
echo 123567 > file1
echo 123567 > file2
echo 123567 > file3
echo helloworld > file4
查找内容:
find ./ | xargs grep -Hn 'hello'
查找结果:
./file4:1:helloworld

猜你喜欢

转载自qi20088.iteye.com/blog/2249456