简体   繁体   English

将ls输出输出到scp命令

[英]Pipe ls ouput to scp command

I have the following ls command lists the first 93 files 我下面的ls命令列出了前93个文件

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 | 我收到一条错误消息,说ls -lrt | head -93: No such file or directory head -93:没有这样的文件或目录

Can someone tell me what im doing wrong please? 有人可以告诉我我做错了什么吗?

I assume that you want to transfer the first 93 files to the remote system. 我假设您想将前93个文件传输到远程系统。 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 . 而且,您不希望ls列表,因此将-l替换为-1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM