12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

zipやtar.gzの中身に対してgrepする

Last updated at Posted at 2016-10-19

ログやらバックアップファイルって、どんどん貯まるので圧縮して保管したいですよね。
でも、中身を調べるときにいちいち解凍するのは面倒です。
そんなときは、解凍コマンドとgrepをパイプで繋ぐと便利です。
※zip形式の場合、zgrepを使ったほうが簡単で便利です。(余計な出力もありません)

zipの場合

zgrep keyword log.zip #おすすめ
unzip -c log.zip | grep keyword #汎用的な方法

tar.gzの場合

tar -O -xvf log.tar.gz | grep keyword
12
10
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?