Linuxで文字列の最初の出現から始めてn行を見つける方法は? [コピー]

Linuxで文字列の最初の出現から始めてn行を見つける方法は? [コピー]

開発者とログを共有する必要があります。彼らは引き続きより多くのログを要求してきました。だから私はLinuxで文字列が最初に発生した後に1000行程度をgrepする方法があるかどうか疑問に思います。

ベストアンサー1

次のオプションが必要です-A。マニュアルページから:

コンテキストライン制御

   -A NUM, --after-context=NUM
          Print  NUM  lines of trailing context after matching lines.  Places a line containing a
          group  separator  (--)  between  contiguous  groups  of  matches.   With  the   -o   or
          --only-matching option, this has no effect and a warning is given.

   -B NUM, --before-context=NUM
          Print  NUM  lines of leading context before matching lines.  Places a line containing a
          group  separator  (--)  between  contiguous  groups  of  matches.   With  the   -o   or
          --only-matching option, this has no effect and a warning is given.

   -C NUM, -NUM, --context=NUM
          Print  NUM  lines  of  output context.  Places a line containing a group separator (--)
          between contiguous groups of matches.  With the -o or --only-matching option, this  has
          no effect and a warning is given.

おすすめ記事