Below are the files in my InputLocation in local server
-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
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 ).
You have two options:
(Ugly, not recommended): Use eval
.
eval scp ${InputLocation}/*.{$FilesExtnsToBeTransfered} ${user}@${HostName}:$OutputPath
Put the desired file extensions in an array:
EXTNS=( jpeg xml ) for i in "${EXTNS[@]}"; do scp ${InputLocation}/*.$i ${user}@${HostName}:$OutputPath done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.