0
1

More than 5 years have passed since last update.

findした結果をディレクトリ構造そのまま移動

Last updated at Posted at 2016-12-24

大量のファイルを、ディレクトリを保ったまま移動したくなった。

他にいい方法が絶対あると思うが、とりあえず上手くいったのでこれで良しとする。

またfindで拡張子を複数指定する方法も調べたので合わせてメモしておく。

cd /path/to/file
find /path/to/file -regextype posix-extended -regex '.*\.(jpg|png)' -print0 |
    xars tar cv -T - --null | bash -c 'cd ~; tar x'

最後のように、bash -cで標準入力を渡せるのが目から鱗でした。

参考

この記事のように、

find -name "hoge*" -print0 | xargs -0 tar cvzf hoges.tar.gz

してはまってました。

ありがとうございます。

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