在Linux中,可以使用grep
命令进行关键字查找
grep [options] keyword file
其中,options
是可选的搜索参数,keyword
是要查找的关键字,file
是要在其中查找的文件。
grep "example" file.txt
grep -n "example" file1.txt file2.txt
grep -i "example" file.txt
grep -E "example[0-9]" file.txt
grep -r "example" /path/to/directory
grep "example" file.txt > result.txt
grep -n "example" file.txt
这些只是grep
命令的一些基本用法,grep
还有许多其他选项和功能,可以参考其手册页以获取更多信息:
man grep
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:linux关键字查找如何优化