![]() |
String Substiution. Whitespace?
Hi all! :D
I've got a little bash script that basically takes my directory path to the "My Documents" folder. Instead of the space, I've inserted a special sequence that I want replaced with "\ " so that I can cd into that directory. However, I get an interesting result. Here's the Script: :
#!/bin/bashHere's the output when I run my file: :
/users/cs/study/gordon/My\ DocumentsSo the echo shows that the "\ " was put into the variable, but when I try and cd into it, it cuts off at the "My\". Does the string substitution put in something unique instead of just a whitespace? Am I using this correctly? Thanks in advance for any insight. :D |
Try this:
:
#!/bin/bashWas there a particular reason that you were avoiding the use of the space in the directory name? If not, this will work out for you. |
Ah ha! The quotes MegaArcon! The quotes! Why thank you Infinite Recursion. Looking at your code helped to spark what I was missing. Instead of subbing in "\ " I can just sub in " " and surround my variable with double quotes for the cd.
New code: :
#!/bin/bashNew output: :
/users/cs/study/gordon/My DocumentsAh, good ol' bash. Thanks again. :D |
You're welcome :)
|
| All times are GMT -5. The time now is 1:47 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC