Tips and tricks for the command line How to generate a path with escaped spaces and special characters printf %q "~/my/very stupid/path/with spaces/" output will be: \~/my/very\ stupid/path/with\ spaces/% Don't use escaped path within quotation marks "" or ''!