0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ターミナルでソートして最新のファイルをコピー

Last updated at Posted at 2017-09-05

ググっても出てこなかったので、メモ代わりに書きます。

わかりにくかった場合は質問してください。

ターミナルでソートして最新のファイルをコピー

コード

auto_move.sh
ls -dr /[PATH]/* | head -n 1 | xargs gcp -rt [PATH]

gcpって?

gcp == cp

と考えて良さそうです。

Macの場合デフォルトでcp -tが使えないため、coreutilsをインストールをしgcp -tを利用しました。

coreutilsをインストールするためには、MacPortsも必要となるため、インストールしてない場合はこちらのインストールも必要。

cp -tって?

-tオプションとは、 cp PATH1 PATH2cp PATH2 PATH 転置(Transpose)のtです。

参考:
Mac OS XへのMacPortsインストールとか設定とかコマンドの使い方メモ
Macでxargsを使ってcpする

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?