sftp -oIdentityFile=keys/public_key -oPort=555 -oUser=anonymous -oHostname=proxy-someserver.abcx.com $host << EOF lcd $file_dir cd $local_dir ls bye EOF When I run the above script it displays the list of files in the directory...I want to get that list in a array and loop through it to download all the files so when I does this @files=`ls` echo $files it says invalid command...