0

I am trying to move all the *.csv files to another folder on server but every time i get access failed error , I am able to get all the files to local server using mget but mv fails everytime , i can see the file on the server and got full permissions on the files, sh script is not working with wild characters. struck here with the simple command .

Download to local directory
localDir="/home/toor/UCDownloads/"
[ ! -d $localDir ] && mkdir -p $localDir
#sftp in the file directory to be downloaded
remoteDir="/share/CACHEDEV1_DATA/Lanein1/Unicard/"

#The file to be downloaded is fileName
lftp -u ${sftp_user},${password} sftp://${host}:${port}<<EOF
PS4='$LINENO: '
set xfer:log true
set xfer:log-file "$logfileUCARC"
set xfer:clobber true
set xfer:auto-rename true
debug 9
cd ${remoteDir}
lcd ${localDir}
#mget  *.CSV
ls -l
mv  "/share/CACHEDEV1_DATA/Lanein1/Unicard/"*.csv  "/share/CACHEDEV1_DATA/Lanein1/Unicard/Archives/"
#rm /share/CACHEDEV1_DATA/Lanein1/Unicard/!(*.pdf)
bye
EOF
ceving
  • 21,900
  • 13
  • 104
  • 178
Kiran V
  • 69
  • 5
  • 16
  • The mv "/share/CACHEDEV1_DATA/Lanein1/Unicard/"/*.csv "/share/CACHEDEV1_DATA/Lanein1/Unicard/Archives/" command doesn't look right with too many forward slashes. Try mv "/share/CACHEDEV1_DATA/Lanein1/Unicard/"*.csv "/share/CACHEDEV1_DATA/Lanein1/Unicard/Archives/" – Raman Sailopal Sep 21 '21 at 08:38
  • No Raman, i even tried that . its not working – Kiran V Sep 21 '21 at 09:00

1 Answers1

0

This is not a shell or Bash problem. It is a LFTP problem.

From the manual of LFTP:

mv file1 file2

Rename file1 to file2. No wildcard expansion is performed.

LFTP just does not support what you asking for. It will treat *.csv as a part of the file name.

See here for an alternative.

ceving
  • 21,900
  • 13
  • 104
  • 178