Escape spaces with sed

When dealing with file paths, you may need to escape spaces. You can do this using sed.

#!/bin/sh

p = "/var/lib/vmware/Virtual Machines"
echo $p
q = $(echo $p | sed 's/ /\\ /g')
echo $q

Output:

/var/lib/vmware/Virtual Machines
/var/lib/vmware/Virtual\ Machines
Last modified: 11/05/07 13:41:31
Go to top

Related Pages

No related pages or links.

Login/out

Login

Forgot Password?
Go to top
Go to top