0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

複数のディレクトリにまたがる、GZファイルを一括でzcatする

Last updated at Posted at 2025-06-16

結論から書くと、以下のコマンドでいけます。

find ./ -name "*.gz" -exec zcat {} +
もしくは
find ./ -name "*.gz" | xargs zcat

xargsのほうがなんとなく良さそう。

こういう階層構造のときに利用できます。

$ tree .
.
├── 01
│   ├── 999999999999__app.hoge-hoge-alb._20250601T0000Z_99.88.77.66_31xyjfrv.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250601T0020Z_99.88.77.66_2vbnoiva.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250601T0030Z_1.2.3.4_3qlhjkt2.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250601T0035Z_99.88.77.66_2tu71fv6.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250601T0040Z_1.2.3.4_2g2agy2d.log.gz
│   └── 999999999999__app.hoge-hoge-alb._20250601T2350Z_1.2.3.4_3q5syo7x.log.gz
├── 02
│   ├── 999999999999__app.hoge-hoge-alb._20250602T0025Z_1.2.3.4_2bgrhg8v.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250602T0105Z_55.44.33.11_1gx93fvf.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250602T0110Z_1.2.3.4_1p6c19sx.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250602T2315Z_55.44.33.11_3nskwjbq.log.gz
│   └── 999999999999__app.hoge-hoge-alb._20250602T2335Z_1.2.3.4_4bu0i2xm.log.gz
├── 03
│   ├── 999999999999__app.hoge-hoge-alb._20250603T0010Z_1.2.3.4_30hzkuem.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250603T0035Z_1.2.3.4_69c8hdp1.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250603T2340Z_1.2.3.4_5pxba6zq.log.gz
│   └── 999999999999__app.hoge-hoge-alb._20250603T2350Z_55.44.33.11_4j8p4h58.log.gz
├── 04
│   ├── 999999999999__app.hoge-hoge-alb._20250604T0000Z_55.44.33.11_3dycvjpr.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250604T0015Z_55.44.33.11_mr07oq1y.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250604T0050Z_1.2.3.4_4pbrzh5o.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250604T2330Z_55.44.33.11_4084h0j5.log.gz
│   └── 999999999999__app.hoge-hoge-alb._20250604T2340Z_55.44.33.11_4jwyi6z4.log.gz
├── 05
│   ├── 999999999999__app.hoge-hoge-alb._20250605T0010Z_99.88.77.66_2y9qq0a3.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250605T0010Z_55.44.33.11_4e1q822k.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250605T0020Z_99.88.77.66_1b5rmtfu.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250605T0025Z_99.88.77.66_1r7tjmta.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250605T0350Z_55.44.33.11_4d7orlit.log.gz
│   ├── 999999999999__app.hoge-hoge-alb._20250605T0355Z_55.44.33.11_4idbf00p.log.gz
└── 16
    ├── 999999999999__app.hoge-hoge-alb._20250616T0010Z_55.66.77.88_4kqwu9cy.log.gz
    ├── 999999999999__app.hoge-hoge-alb._20250616T0010Z_111.222.333.444_20qq7n9q.log.gz
    ├── 999999999999__app.hoge-hoge-alb._20250616T0030Z_55.66.77.88_4kf308fg.log.gz
    ├── 999999999999__app.hoge-hoge-alb._20250616T0050Z_55.66.77.88_6a0m7psi.log.gz
    ├── 999999999999__app.hoge-hoge-alb._20250616T0455Z_55.66.77.88_3kz8r60b.log.gz
    ├── 999999999999__app.hoge-hoge-alb._20250616T0500Z_55.66.77.88_2i4bb4jx.log.gz
    ├── 999999999999__app.hoge-hoge-alb._20250616T0500Z_111.222.333.444_znd2ay5y.log.gz
    ├── 999999999999__app.hoge-hoge-alb._20250616T0510Z_55.66.77.88_4zlz6pet.log.gz
    ├── 999999999999__app.hoge-hoge-alb._20250616T0515Z_111.222.333.444_5ckmgw0p.log.gz
    └── 999999999999__app.hoge-hoge-alb._20250616T0520Z_111.222.333.444_17no72t3.log.gz

find, zcat, xargsは今後もずっと使いそうなコマンドです。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?