When I use the \"tab\" key in bash (when you have started to type the filename and you want it to complete), bash escapes the filename correctly, a
bash
Use printf (1):
printf
x='a real \good %* load of c$rap' x=$(printf '%q' "$x") echo $x
will return
a\ real\ \\good\ %\*\ load\ of\ c\$rap