LINUXUSER 指令專區
指令名稱
grep
使用權限
使用方式
grep [--[ABC] NUM] [--EFGHLUVZabchilnqrsuvwxyz] [-e PATTERN] [-f FILE] [-d ACTION] <字串> <FILENAME> [--help] [--version]
說 明
參 數
(1) Regexp selection and interpretation:
(2) Miscellaneous:
(3) Output control:
(4) Context control:
範 例
1. 尋找副檔名為".txt"且檔案內容含有"hello"這個字串的所有檔案名稱,並列出該列與其前三列的內容 grep -B3 hello *.txt 2. 列出副檔名為".txt",且檔案內容沒有"hello"這個字串的檔案名稱 grep -L hello *.txt