在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