2013-10-15 85 views
7

我有以下ls命令列出的第一個93個文件管LS輸出中以scp命令

ls -lrt | head -93 

但是當我嘗試管道這給scp像

scp 'ls -lrt | head -93' {} [email protected]:~/DIR1/SUBDIR 

我收到一個錯誤說LS - lrt |頭-93:沒有這樣的文件或目錄

有人可以告訴我什麼即時做錯了請嗎?

回答

12

我假設你想把前93個文件傳送到遠程系統。如果是這樣,請嘗試:

scp $(ls -1rt | head -93) [email protected]:~/DIR1/SUBDIR 

$(...)表示Command Substitution。此外,您不希望從ls列出的長的,因此用-1代替-l

+0

輝煌,謝謝! – van

+0

對不起 - 慢接受:) – van

+0

這也應該工作scp'ls -1rt |頭-93'test @ testserver:〜/ DIR1/SUBDIR –