user1020358
user1020358

Reputation: 33

bash: syntax error near unexpected token

I have this alias in .bashrc:

alias clone='while ! rsync --rsh=ssh -avP --delete --stats --compress-level=9 $1/ $2:$3 | grep -q "Number of files transferred: 0" ; do echo -n .; sleep 1; done'

Got error when I do this:

clone /d/root/tmp [email protected] /temp
bash: syntax error near unexpected token `/d/root/tmp'

Everything works fine if I put this in a script file:

#!/bin/sh
while ! rsync --rsh=ssh -avP --delete --stats --compress-level=9 $1/ $2:$3 | grep -q "Number of files transferred: 0" ; do echo -n .; sleep 1; done

and execute the script file like so:

./clonescript /d/root/tmp [email protected] /temp

Any help is much appreciated.

Upvotes: 3

Views: 1481

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798666

Aliases do not have positional arguments. create a function instead.

clone() {
  while ...
   ...
}

Upvotes: 3

Related Questions