![]() |
Spaces in path names
Hello Everyone,
I am new here and just started shell scripting. I thought I would start with creating a shell script as a solution to one of my problems. I need some help with variables and path names (especially spaces in pathnames) here. I am trying to use my firefox bookmarks on linux with that on windows synchronously but I am getting errors with the path variable for the windows profile folder since it has spaces in its pathname. For Example: :
$ cd /mnt/hda1/Documents\ and\ Settings/:
$ HDA1="/mnt/hda1/Documents\ and\ Settings/":
bash: cd: /mnt/hda1/Documents\: No such file or directoryWith/out quotes, backslashes, all same.. I understand that shell does not like spaces. What should I write instead since I cannot change the pathname? Any suggestions please? Thank in advance |
Re: Spaces in path names
:
Since everything is "encased" in the quotation marks, spaces shouldn't be a problem. :) |
Re: Spaces in path names
Quote:
I already tried that but I am getting same thing.. :( :
$ HDA1="/mnt/hda1/Documents and Settings" |
Re: Spaces in path names
I'll take a whack at guessing:
:
HDA1="\"/mnt/hda1/Documents and Settings\""Or: :
HDA1="/mnt/hda1/Documents\\ and\\ Settings" |
Re: Spaces in path names
Quote:
:
$ HDA1="\"/mnt/hda1/Documents and Settings\"":
$ HDA1="/mnt/hda1/Documents\\ and\\ Settings"Keep it coming please.. I am sure we will work this out by the sun rise.. ;) |
Re: Spaces in path names
It may have something to do with whether or not you're using single or double quotes if you have variables in your script somewhere that have a name in your directory path. If so, you will have to either use single quotes or use an escape character to ignore the variable. More Info
:
$ HDA1="\"/mnt/hda1/Documents and Settings\""It may be since you are using HDA1 as a variable, and hda1 is in your path, that you may have to escape the hda1 to get it to work; or use single quotes. |
Re: Spaces in path names
a shot in the dark but change jessehks:
:
$ HDA1="/mnt/hda1/Documents and Settings"to: :
$ HDA1="/mnt/hda1/Documents and Settings"? has been a while since i've written a shell script |
Re: Spaces in path names
Quote:
I tried all possible combinations with double quotes, single quote, slashs, backslash in defining the variable all same: linefeeds after space. :( I read that -1 (digit one, not lower L) parameter may prevent new line feed for ls command but I could not implement it to cp or mv commands :S Thanks for the link by the way . |
Re: Spaces in path names
Quote:
Thanks you all for your interest :) I will be right back :lol: |
Re: Spaces in path names
I just wanted to share my final script which works just fine.
Since the installed add-ons are not compatible for both linux and windows at a time, using same profile folder with -ProfileManager was a bit of useless thus I really needed this thing: :
#!/bin/shI hope it is useful for somebody else out there too :) |
| All times are GMT -5. The time now is 2:12 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC