LoginSignup
4
3

More than 3 years have passed since last update.

いろいろな位置に散在したファイルを集める方法

Last updated at Posted at 2016-12-03

きっかけ

結構あります。こういう時。

解決方法

いろいろありますけど find-exec オプションを使うのが簡単です。
例えば下記のような状態で、 *.pdbfoo/ に移したいとします。

$ tree
.
├── 1_hoge
│   └── a.pdb
├── 2_hoge
│   └── b.pdb
└── foo

3 directories, 2 files

find の結果を -execmv に渡します。
{}find の結果が入ります。

コマンドの終了位置には \; を入れてください。

$ find [1-9]*/* -exec mv {} foo \;

実行するとこうなります。

$ tree
.
├── 1_hoge
├── 2_hoge
└── foo
    ├── a.pdb
    └── b.pdb

他のやり方

思いついたら追記するかも

ファイル名をグロブしてforループでmv

$ for i in [1-9]*/*; do mv ${i} foo; done
4
3
1

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
4
3