LoginSignup
0
0

More than 5 years have passed since last update.

scpコマンドで最新のファイルをリモートから転送

Posted at

リモート側の特定のディレクトリにあるファイルのうち、
最新のファイルをローカルにコピーしたかった。

※ リモート側には作成日がファイル名に含まれるファイルが存在するが、
 作成した日にscpするとは限らなかったので、システム日付からはコマンドを生成できなかった

$ fname=`ssh hoge.jp 'ls -1t /home/hoge/data/current/table_*.tsv|head -n 1'` 
$ scp hoge.jp:${fname} ~/Downloads

きっとまた同じことを調べるんだろうなぁと思ってここに残しておきます。

一旦、下書きに書いて再度眺めると、もしかしたら1行で書けるの?
と思ったが、それは後々確認します。
 

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