LoginSignup
8
9

More than 5 years have passed since last update.

特定の拡張子だけtarで固める(hoge.tgzの生成)

Last updated at Posted at 2015-01-09

例えばdir/以下にある拡張子 .cpp .htmlをhoge.tgzとして固めたい場合

$ find ./ | grep "\.\(cpp\|html\)$" | xargs tar czvf hoge.tar.gz

解説
findで固めたいディレクトリ以下のファイルリストを作る、grepでリストから特定の拡張子を含むファイルを選択する。リストをパイプででtarにわたす。
逆に特定のファイルを除外したい場合はtar に--excludeオプションがあるのでそれを使う。

8
9
5

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
8
9