-1

Below are the files in my 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 know transfering files of same extension as below

    /usr/bin/sftp ${user}@${HostName} <<EOF
    cd $InputPath
    lcd $OutputPath
    put *.csv
    exit
EOF

scp ${InputPath}/*.csv ${user}@${HostName}:$OutputPath

But every time when i run the script i need to transfer only files with xml and jpeg extensions. ssh,scp,SFTP can be used. Any hep please??

user2531569
  • 609
  • 4
  • 18
  • 36

1 Answers1

0

You can try with something like this:

*.{jpeg,xml}

All together:

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

Test

$ ls
a.jpeg  a.png  a.xml 
$ ls *{jpeg,xml}
a.jpeg  a.xml
fedorqui
  • 275,237
  • 103
  • 548
  • 598
  • Thanks.Above cmd is working.Now i am trying to take fileExtns into a variable as Extns=jpeg,xml scp ${InputPath}/*.{$Extns} ${user}@${HostName}:$OutputPath But this is throwing some error. Any way to handle this? – user2531569 Sep 26 '13 at 06:54
  • As you can read in http://stackoverflow.com/a/18981544/1983854 , `Brace expansion occurs before variable expansion`, so I guess there is no way to do so. – fedorqui Sep 26 '13 at 08:31