I have a set of scripts that I use to upload files via FTP, and then delete them from the server.
It works as follows:
for dir in `ls /volume1/auto_downloads/sync-complete` do if [ "x$dir" != *"x"* ] then echo "DIR: $dir" echo "Moving out of complete"
Now $ dir may be “This is a file”, which works fine.
I have a problem with special characters, for example:
- "This is (a) a file"
- This is a file and more.
have a tendency to error:
bash: -c: line 0: syntax error near unexpected token `(' bash: -c: line 0: `mv -v '/home/dan/Downloads/complete/This is (a) file' /home/dan/Downloads/downloaded'
I can’t figure out how to avoid this, as the variable gets evaluated and the command gets the escaped label. I tried various combinations of escape characters, letter quotes, regular quotes, etc.
source share