共計 526 個字符,預計需要花費 2 分鐘才能閱讀完成。
grep 命令用于查找文件中包含特定字符串的行。下面是 grep 命令的基本用法:
-
grep string file
: 在指定文件中查找包含特定字符串的行。例如:grep hello file.txt
將在 file.txt 中查找包含字符串 "hello" 的行。 -
grep -i string file
: 在查找時忽略大小寫。例如:grep -i hello file.txt
將在 file.txt 中查找包含字符串 "hello" 的行,不區分大小寫。 -
grep -r string directory
: 在指定目錄及其子目錄下查找包含特定字符串的行。例如:grep -r hello /path/to/directory
將在指定目錄下遞歸查找包含字符串 "hello" 的行。 -
grep -v string file
: 查找不包含特定字符串的行。例如:grep -v hello file.txt
將在 file.txt 中查找不包含字符串 "hello" 的行。 -
grep -n string file
: 顯示匹配行的行號。例如:grep -n hello file.txt
將顯示 file.txt 中包含字符串 "hello" 的行的行號。
這些只是 grep 命令的一些基本用法,還有更多的選項和用法可以查看 grep 命令的幫助文檔。
丸趣 TV 網 – 提供最優質的資源集合!
正文完