[LBo] running commands on filenames with spaces

Billy Pollifrone billy at silverbaseball.com
Sat May 12 09:37:52 CEST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Roseman wrote:
> Hi,
> 
> I was trying to run a chmod command on a filename containing spaces,  and
> bash thought that I was trying to run the command on each word in the
> filename as if it was a different file.  Is there a character i can insert
> instead of spaces so that bash will process the chmod correctly?
> 
> Thanks
> Dave

Escape the space with a backslash.

chmod a+w my\ file\ with\ annoying\ spaces.txt

or... place the filename in spaces

chmod a+w "my file with annoying spaces.txt"

or use bash completion to have the shell put the escapes in for you.

- --
Billy Pollifrone
billy @ silverbaseball . com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGRW7QX+/yaB/12JsRAme/AJ0SiFBwwzeAG8bUGpto+/bN1rM6dACghUXU
APYP0hNLc5TvTSfNxfcqbCo=
=m9Mz
-----END PGP SIGNATURE-----


More information about the QnA mailing list