Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pipe ls ouput to scp command

Tags:

linux

scp

I have the following ls command lists the first 93 files

ls -lrt | head -93 

but when i try piping this to scp like

scp 'ls -lrt | head -93' {} test@testserver:~/DIR1/SUBDIR

I recieve an error saying ls -lrt | head -93: No such file or directory

Can someone tell me what im doing wrong please?

like image 725
van Avatar asked Oct 15 '13 16:10

van


1 Answers

I assume that you want to transfer the first 93 files to the remote system. If so, try:

scp $(ls -1rt | head -93) test@testserver:~/DIR1/SUBDIR

$(...) denotes Command Substitution. Moreover, you don't want the long listing from ls, so replace -l with -1.

like image 155
devnull Avatar answered Sep 28 '22 21:09

devnull