助け合いフォーラム
トピック一覧に戻る
トピック タイトル
問題ID: 34335「tar コマンドのオプション[-z]の必要性について」
フォーラム
最強WEB問題集LinuC/LPIC Lv1 101
投稿ユーザ(投稿日)
(2020/7/16)
本文
■問題文では、アーカイブファイルを展開せずに表示したいと記載されており、正解は、tar ftvz test.tar.gzとなっています。
CentOS7で試したところ、オプション[-z]の有無に関係なくアーカイブファイルの内容が確認できました。

tar ftvz archive1.tar.gz [-z]有り
tar ftv archive1.tar.gz [-z]無し

オプション[-z]が何故必要なのか、どなたかご教示いただけますでしょうか。


[root@localhost Desktop]# ls
[root@localhost Desktop]#
[root@localhost Desktop]# touch {1..3}.txt
[root@localhost Desktop]#
[root@localhost Desktop]# tar -cf archive1.tar {1..3}.txt
[root@localhost Desktop]# ls
1.txt 2.txt 3.txt archive1.tar
[root@localhost Desktop]#
[root@localhost Desktop]# gzip archive1.tar
[root@localhost Desktop]#
[root@localhost Desktop]# ls
1.txt 2.txt 3.txt archive1.tar.gz
[root@localhost Desktop]#
[root@localhost Desktop]# tar ftv archive1.tar.gz
-rw-r--r-- root/root 0 2020-07-16 10:45 1.txt
-rw-r--r-- root/root 0 2020-07-16 10:45 2.txt
-rw-r--r-- root/root 0 2020-07-16 10:45 3.txt
[root@localhost Desktop]#
[root@localhost Desktop]# tar ftvz archive1.tar.gz
-rw-r--r-- root/root 0 2020-07-16 10:45 1.txt
-rw-r--r-- root/root 0 2020-07-16 10:45 2.txt
-rw-r--r-- root/root 0 2020-07-16 10:45 3.txt

■環境
CentOS Linux 7
GNOME バージョン 3.28.2
OSの種類 64ビット
仮想化 VMware
レス一覧

トピック一覧に戻る
フォーラムTopへ

Ping-tモバイルTOP

Copyright (c) 2010
Ping-t All rights reserved.