Your for-loop adds to $files
like this:
files="$files file_$i.dump"
# $files will look like this when the loop is done:
" file_1000000.dump file_1100000.dump file_1200000.dump ..."
Now look what happens when you use that with scp
:
scp user@abc.abc.com:/user/ file_1000000.dump file_1100000.dump file_1200000.dump ./
That will clearly not work.
If your files really are in subdir /user
(sure you don't mean ~user
?), you can use {}
to group them. Add them to $files
in your loop like this:
files="$files,file_$i.dump"
# When finished, it will look like this (yes leading ,)
",file_1000000.dump,file_1100000.dump,file_12000000.dump,..."
Now call scp using bash variable substitution to remove the leading ,
scp user@abc.abc.com:/user/{${files#,}} ./
If this feels too complicated and you don't mind the extra transfer-time, maybe just scp
the files one by one in the loop, as suggested in an other answer...