Re: BASH Programming: spaces ignored

From: Måns Rullgård (mru_at_inprovide.com)
Date: 05/30/05


Date: Mon, 30 May 2005 16:58:49 +0200


"shakahshakah@gmail.com" <shakahshakah@gmail.com> writes:

> sean@mail.capitalgenomix.com wrote:
>> I'm having difficulty with a BASH script that I'm attempting to write.
>> I'm attempting to change directories to a path with a space in the name
>> and it appears that the spaces are being dropped. Following is the
>> script:
>>
>> #!/bin/bash
>> fileserver_path="/mnt/fs/Documents/DS\ -\ Datasheets/"
>>
>> cd $fileserver_path
>
> Does the following work for you?
> cd "$fileserver_path"

Always quote string with variables in them, no exceptions. In this
case, you get a harmless failure. Another time, you might end up
wiping out half your data by mistake.

-- 
Måns Rullgård
mru@inprovide.com

Quantcast