简体   繁体   English

将不同扩展名的文件从一台服务器转移到Linux上的另一台服务器?

[英]Transfer files of different extensions from one server to another on linux?

Below are the files in my InputLocation in local server 以下是我在本地服务器中InputLocation中的文件

-rw-r----- 1 root root 0 Sep 25 15:03 one.xml
-rw-r----- 1 root root 0 Sep 25 15:03 two.xml
-rw-r----- 1 root root 0 Sep 25 15:03 data.csv
-rw-r----- 1 root root 0 Sep 25 15:03 free.png
-rw-r----- 1 root root 0 Sep 25 15:04 loaded.jpeg

I am able to transfer files using the below command 我可以使用以下命令传输文件

scp ${InputPath}/*.{jpeg,xml} ${user}@${HostName}:$OutputPath

But i am trying to put the extns in a variable as below 但是我试图将extns放在如下变量中

FilesExtnsToBeTransfered=jpeg,xml
scp ${InputLocation}/*.{$FilesExtnsToBeTransfered} ${user}@${HostName}:$OutputPath

But i am getting the below exception though the files are available 但是我可以得到以下异常,尽管文件可用

InputLocation/*.{jpeg,xml}: No such file or directory

Any help please? 有什么帮助吗?

Saying: 说:

FilesExtnsToBeTransfered=jpeg,xml
echo {$FilesExtnsToBeTransfered}

would result in {jpeg,xml} ( brace expansion would not be performed ). 将导致{jpeg,xml}不执行大括号扩展 )。

You have two options: 您有两种选择:

  1. (Ugly, not recommended): Use eval . (不建议这样做):使用eval

    eval scp ${InputLocation}/*.{$FilesExtnsToBeTransfered} ${user}@${HostName}:$OutputPath

  2. Put the desired file extensions in an array: 将所需的文件扩展名放入数组中:

 EXTNS=( jpeg xml ) for i in "${EXTNS[@]}"; do scp ${InputLocation}/*.$i ${user}@${HostName}:$OutputPath done 

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

相关问题 使用python将文件从一个目录转移到另一个目录 - Transfer files from one directory to another if they match a condition using python 使用wget将所有内容从一个共享服务器传输到另一个 - Transfer all content from one shared server to another using wget? 如何在Linux / Unix中将多个文件从一个扩展名重命名为另一个扩展名? - How to rename multiple files from one extension to another in Linux / Unix? 将包从一个 conda 环境转移到另一个环境 - transfer packages from one conda environment to another 如何将mtime从一个文件传输到另一个文件 - how to transfer the mtime from one file to another 从远程Linux服务器将文件传输到Hadoop HDFS - File Transfer to Hadoop HDFS from remote linux server 将文件从FTP服务器传输到本地UNIX服务器 - Transfer files from FTP server to local unix server Airflow 中从一台服务器到另一台服务器的文件传输 - File transfer from one server to other server in Airflow Unix脚本,用于将文件(在特定时间段内)从一台服务器复制到另一台服务器 - Unix script to copy files (which came in a particular duration) from one server to another server 如何使用Bamboo将文件从一台服务器移动到另一台服务器? - How do I move files from one server to another server using Bamboo?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM