LoginSignup
0
0

More than 1 year has passed since last update.

tarコマンドでアーカイブファイル内から指定した個数のファイルを取り出す

Last updated at Posted at 2022-05-26

tarコマンドでアーカイブファイル内から指定した個数のファイルを取り出す

##100件取り出す
###アーカイブファイル内にディレクトリがない場合

tar tf logfile.tar
hoge1.txt
hoge2.txt
hoge3.txt
hoge4.txt
....
$ tar xvf logfile.tar $(tar tf logfile.tar | head -100 )

###アーカイブファイル内でディレクトリ分けされている場合

tar tf logfile.tar
log/
log/hoge1.txt
log/hoge2.txt
....
data/
data/foo1.txt
data/foo2.txt
...
$ tar xvf logfile.tar $(tar tf logfile.tar log/ | head -100 |sed '1d' )

sortなどを組み合わせて、サイズが大きい順に取り出したりもできる

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