最終更新:2023-04-13 (木) 07:11:04 (376d)  

grep
Top / grep

文字列を検索する

grep [オプション] [パターン] [ファイル]

メモ

  • grep -r "Make Caps Lock" /usr/*

ps aux | grep httpd
grep "hoge" *.txt

パラメータ

  • grep -q--quiet, --silentQuiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected. Also see the -s or --no-messages option.
    grep -E?--extended-regexp

再帰

grep -r PATTERN target_directory

オプション

-i--ignore-case
-v--invert-match

マッチした前後を表示

-A num

  • --after-context=num
  • Print num lines of trailing context after matching lines.

-B num

  • --before-context=num
  • Print num lines of leading context before matching lines.

-C num

  • -num
  • --context=num
  • Print num lines of leading and trailing output context.

関連

参考