查找文件:
[[email protected] admin]# find . -type f -name "a.txt" ./Downloads/hadoop-2.10.0/a.txt
拥有遍历文件夹功能的 查找关键字 文件、文件夹:
[[email protected] admin]# vi a [[email protected] admin]# find /home/admin/ -type f | xargs grep "i like apple" Binary file /home/admin/.cache/tracker/meta.db matches Binary file /home/admin/.cache/tracker/meta.db-wal matches grep: /home/admin/.cache/yelp/WebKitCache/Version: No such file or directory grep: 14/salt: No such file or directory grep: /home/admin/Downloads/hadoop-2.10.0/share/hadoop/yarn/webapps/ui2/assets/images/datatables/Sorting: No such file or directory grep: icons.psd: No such file or directory /home/admin/a:i like apple (把包含i like apple 那一行取出, 如果是i like apple too, 这里显示的就是i like apple too) [[email protected] admin]#
[[email protected] admin]# cat a
i like apple
hahahaha
grep:查找指定目录/home/admin及其子目录(如果存在子目录的话)下所有文件中包含字符串"i like apple too"的文件,并打印出该字符串所在行的内容,使用的命令为:
[[email protected] admin]# grep -r "i like apple" /home/admin Binary file /home/admin/.cache/tracker/meta.db matches /home/admin/a:i like apple too
原文地址:https://www.cnblogs.com/watermarks/p/12681641.html
时间: 2024-11-08 15:30:32