If you are using bash, you can use its builtin printf’s %q formatter (type help printf
in bash):
FILENAME=$(printf %q "$FILENAME")
This will not only quote space, but also all special characters for shell.
If you are using bash, you can use its builtin printf’s %q formatter (type help printf
in bash):
FILENAME=$(printf %q "$FILENAME")
This will not only quote space, but also all special characters for shell.