ウェブサイト検索

Dtrx - Linux 用のインテリジェントなアーカイブ抽出 (tar、zip、cpio、rpm、deb、rar) ツール


Linux の tar.gztar.bz2tbz コマンドを使用しているときに、誰もが一度はこんな状況に直面したことがあるかもしれません。 。非常に多くのアーカイブ タイプ、覚えなければならないコマンドが非常に多くあります。dtrx ツールのおかげで、もうその必要はありません。

  1. Linux でアーカイブを作成および抽出するための 18 の Tar コマンド
  2. Linux で RAR ファイルを開いて抽出し、作成する方法

DTRXとは何ですか?

Dtrx は「Do The Right Extraction」の略で、*nix システム用のオープンソースで非常に効果的なコマンドライン アプリケーションであり、アーカイブ抽出の作業を簡単に簡素化します。

dtrx コマンドは、「tar -zxvf」または「tar -xjf」コマンドに代わるもので、アーカイブを抽出する単一のコマンドを提供します。 tarziprpmdebgemなど、さまざまな形式で保存できます。 >、7zcpiorarなど。またbzip2gzipなどで圧縮されたファイルの解凍にも使用できます。

デフォルトでは、dtrx はコンテンツを専用のディレクトリに抽出し、コンテンツの抽出中にユーザーが直面する権限の問題 (権限拒否 など) も修正して、所有者がすべてのコンテンツを読み書きできるようにします。それらのファイル。

Dtrxの機能

  1. 多くのアーカイブ タイプを処理: tar、zip、rar、gz、bz2、xz、rpm、deb、gem、自己解凍 zip ファイル、その他多くの形式の exe ファイルを抽出するための簡単なコマンドが 1 つだけ提供されます。 。
  2. すべてを整理します: アーカイブを独自の専用ディレクトリに抽出します。
  3. 適切なアクセス許可: また、ユーザーは解凍後にすべてのファイルを読み書きできるようになり、アクセス許可はそのまま維持されます。
  4. 再帰的抽出: アーカイブ内でアーカイブを見つけて抽出することもできます。

Linux に Dtrx をインストールする方法

dtrx ツールはデフォルトで Ubuntu リポジトリに含まれており、apt-get を実行してシステムにインストールするだけです。

Debian/Ubuntu/Linux Mint の場合

sudo apt-get install dtrx

RHEL/CentOS/Fedora の場合

Red Hat ベースのシステムでは、dtrx はデフォルトのリポジトリからは利用できません。dtrx スクリプトをダウンロードし、root ユーザーとして以下のコマンドを使用してプログラムをシステム全体にインストールする必要があります。

wget http://brettcsmith.org/2007/dtrx/dtrx-7.1.tar.gz
tar -xvf dtrx-7.1.tar.gz 
cd dtrx-7.1
python setup.py install --prefix=/usr/local
サンプル出力
running install
running build
running build_scripts
creating build
creating build/scripts-2.6
copying and adjusting scripts/dtrx -> build/scripts-2.6
changing mode of build/scripts-2.6/dtrx from 644 to 755
running install_scripts
copying build/scripts-2.6/dtrx -> /usr/local/bin
changing mode of /usr/local/bin/dtrx to 755
running install_egg_info
Creating /usr/local/lib/python2.6/site-packages/
Writing /usr/local/lib/python2.6/site-packages/dtrx-7.1-py2.6.egg-info

dtrxコマンドの使い方

dtrx コマンドはロード・オブ・ザ・ リングで彼ら全員を支配する1つの指輪のようなものです。アーカイブごとに構文を覚える必要はなく、覚えておく必要があるのは dtrx コマンドだけです。

1. 単一のアーカイブの抽出

たとえば、「tecmint27-12-2013.gz」というアーカイブ ファイルを抽出したい場合、フラグを使用せずに dtrx コマンドのみを実行します。

[root@tecmint]# dtrx tecmint27-12-2013.gz

抽出を簡略化する以外にも、ファイルをフォルダーに抽出したり、特定のアーカイブ内の他のすべてのアーカイブを再帰的に抽出したりするなど、他にもたくさんのオプションがあります。

2. 複数のアーカイブの抽出

dtr1.zipdtr2.zip、および dtr3.zip< で構成されるファイル「dtrAll.zip」があるとします。 は、それぞれ dtr1dtr2、および dtr3 で構成されます。最初に手動で dtrAll zip を抽出し、次に dtr1dtr2、および dtr3 をそれぞれ抽出する必要はありません。 dtrx を使用してそれぞれのフォルダーに直接解凍することができ、オプション「a」を選択すると、すべての zip ファイルが再帰的に解凍されます。

[root@tecmint]# dtrx dtrAll.zip
サンプル出力
dtrx: WARNING: extracting /root/dtrAll.zip to dtrAll.1
dtrAll.zip contains 3 other archive file(s), out of 3 file(s) total.
You can:
 * _A_lways extract included archives during this session
 * extract included archives this _O_nce
 * choose _N_ot to extract included archives this once
 * ne_V_er extract included archives during this session
 * _L_ist included archives
What do you want to do?  (a/o/N/v/l) a

抽出後、ls コマンドを使用して抽出されたディレクトリの内容を確認できます。

[root@tecmint]# cd dtrAll
[root@tecmint]# ls 

dtr1  dtr1.zip  dtr2  dtr2.zip  dtr3  dtr3.zip

3. 特定のアーカイブの抽出

その中のアーカイブではなく、最初のアーカイブを抽出したいとします。 N を選択すると、指定されたアーカイブのみが抽出され、そのアーカイブ内の他のアーカイブは抽出されません。

[root@tecmint]# dtrx dtrAll.zip
サンプル出力
dtrx: WARNING: extracting /root/dtrAll.zip to dtrAll.1
dtrAll.zip contains 3 other archive file(s), out of 3 file(s) total.
You can:
 * _A_lways extract included archives during this session
 * extract included archives this _O_nce
 * choose _N_ot to extract included archives this once
 * ne_V_er extract included archives during this session
 * _L_ist included archives
What do you want to do?  (a/o/N/v/l) N

抽出されたディレクトリの内容は、次のように ls コマンドを使用して確認できます。

[root@tecmint]# cd dtrAll
[root@tecmint]# ls

dtr1.zip dtr2.zip dtr3.zip

4. アーカイブの各層を抽出する

アーカイブ内のアーカイブの各レイヤーをケースバイケースで抽出するには、つまり、アーカイブの第 2 レイヤーを抽出するが、第 3 レイヤーは抽出しない場合は、「o」オプションを使用できます。

zip ファイル「dtrNewAll.zip」があり、その内容として「dtrAll.zip」と「dtrNew」が含まれているとします。ここで、「dtrNewAll」と「dtrAll」の内容も抽出するが、dtr1.zipdtr2 の内容は抽出しない場合は、 .zip および dtr3.zip では、以下に示すように「o」および「n」オプションを使用できます。

dtrx dtrNewAll.zip
サンプル出力
dtrNewAll.zip contains 1 other archive file(s), out of 2 file(s) total.
You can:
 * _A_lways extract included archives during this session
 * extract included archives this _O_nce
 * choose _N_ot to extract included archives this once
 * ne_V_er extract included archives during this session
 * _L_ist included archives
What do you want to do?  (a/o/N/v/l) o
dtrAll.zip contains 3 other archive file(s), out of 3 file(s) total.
You can:
 * _A_lways extract included archives during this session
 * extract included archives this _O_nce
 * choose _N_ot to extract included archives this once
 * ne_V_er extract included archives during this session
 * _L_ist included archives
What do you want to do?  (a/o/N/v/l) n

抽出されたディレクトリの内容は、次のように ls コマンドを使用して確認できます。

[root@tecmint]# cd dtrNewAll
[root@tecmint]# ls

dtrAll  dtrAll.zip  dtrNew
[root@tecmint]# cd dtrAll
[root@tecmint]# ls

dtr1.zip dtr2.zip dtr3.zip

最初に「o」オプションを選択します。これは、dtrNewAll 内のすべてのアーカイブが抽出されることを意味します。後で、dtrAll.zip の「n」オプションを選択します。これは、その中のアーカイブが dtr1.zipdtr2.zip であることを意味します。 dtr3.zip は解凍されません。

5. .deb、.rpm、.gem ファイルからメタデータを抽出する

-m」オプションは、.deb.rpm、および .gem アーカイブからメタデータを抽出します。通常のコンテンツの代わりに。コマンドの例を次に示します。

[root@tecmint]# dtrx -m openfire_3.8.2_all.deb 
[root@tecmint]# dtrx -m openfire-3.8.2-1.i386.rpm
[root@tecmint]# ls

conffiles  control  md5sums  postinst  postrm  prerm

dtrx オプションは他にもたくさんあります。「dtrx –help」 を実行すると、利用可能なオプションが一覧表示されます。

[root@tecmint]# dtrx  --help

Usage: dtrx [options] archive [archive2 ...]

Intelligent archive extractor

Options:
  --version             	show program's version number and exit
  -h, --help            	show this help message and exit
  -l, -t, --list, --table      	list contents of archives on standard output
  -m, --metadata        	extract metadata from a .deb/.gem
  -r, --recursive       	extract archives contained in the ones listed
  -n, --noninteractive  	don't ask how to handle special cases
  -o, --overwrite       	overwrite any existing target output
  -f, --flat, --no-directory    extract everything to the current directory
  -v, --verbose         	be verbose/print debugging information
  -q, --quiet           	suppress warning/error messages

参考リンク

dtrx ホームページ

dtrx をぜひ試してみてください。これは、単一のコマンドであらゆる形式のアーカイブ ファイルを解凍できる唯一の強力なコマンド ライン ツールだからです。現時点ではここまでです。コメント欄にメモを残すことを忘れないでください。