Vote count:
0
I have a script which sync's a few files with a remote host. The commands that I want to issue are of the form
rsync -avz ~/.alias user@y:~/.alias
My script looks like this:
files=(~/.alias)
for file in "${files[@]}"; do
rsync -avz "${file}" "user@server:${file}"
done
But the ~ always gets expanded and in fact I invoke the command
rsync -avz /home/user/.alias user@server:/home/user/.alias
instead of the one above. But the path to the home directory is not necessarily the same locally as it is on the server. I can use e.g. sed to replace this part, but it get's extremely tedious to do this for several servers with all different paths. Is there a way to use ~ without it getting expanded during the runtime of the script, but still rsync understands that the home directory is meant by ~?
asked 32 secs ago
Prevent expansion of `~`
Aucun commentaire:
Enregistrer un commentaire