I want to remove multiple files from remote server. I have all files under one array in a script and I call other script which will remove files.
Let output of "${b[@]}" is:
/mnt/DataBK/BackupDropwizardLogs_2015-12-17_04-00-01.tar.gz
/mnt/DataBK/BackupDropwizardLogs_2015-12-17_04-30-01.tar.gz
/mnt/DataBK/BackupDropwizardLogs_2015-12-17_05-00-02.tar.gz
script which will remove file is:
#!/bin/bash
file="$1"
sshpass -p 'password' ssh [email protected] "echo "$file""
while calling bash /tmp/1.sh "'${b[@]}'"
I get error
bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file
And while calling bash /tmp/1.sh "${b[@]}"
it assigns only one file to file variable.
/mnt/DataBK/BackupDropwizardLogs_2015-12-17_04-00-01.tar.gz
Can someone please tell me how to assign value of array containing spaces to file variable in above script.
UPDATE:: It worked by setting declare -a file=("$@")
in other script. But what if want to send more parameter rather than only array?