|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
YANQ (Yet Another Newbie Question)
I have a directory "a b c/x y z"
I would like to assign it an environment variable so I can "cd" to it, as in: A="a b c/x y z";export A so that I can "cd $A". I've tried single quotes, double quotes, backslashes and permutations thereof, but NOTHING works. Any help would be graciously accepted. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
It is working for me: Code:
# a="a b/c d" # cd $a # pwd /root/test/a b/c d Can you post exact commands that you are using? |
| The Following User Says Thank You to bartus11 For This Useful Post: | ||
wel51x (07-10-2012) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
here's what happens to me: Code:
Winstons-MacBook-Pro:bh winstonlee$ a="a b/x y" Winstons-MacBook-Pro:bh winstonlee$ cd $a -bash: cd: a: No such file or directory Winstons-MacBook-Pro:bh winstonlee$ ls -ls "a b" total 0 0 drwxr-xr-x 2 winstonlee staff 68 Jul 10 16:59 x y Winstons-MacBook-Pro:bh winstonlee$ Last edited by Scrutinizer; 07-11-2012 at 02:50 AM.. Reason: please ue code tags |
|
#5
|
|||
|
|||
|
dunno; does this help? Code:
Winstons-MacBook-Pro:bh winstonlee$ echo ++++++++;env|sort;echo ++++++++ ++++++++ Apple_PubSub_Socket_Render=/tmp/launch-BY8Q0h/Render Apple_Ubiquity_Message=/tmp/launch-9h1fCp/Apple_Ubiquity_Message BHTV15=/Users/winstonlee/Desktop/Apps/BrightHouse/iOS Projects/bhn-ios-1.5_05April_Defect697 BHTV2=/Users/winstonlee/Desktop/Apps/BrightHouse/AndroidProjects/bhn-ios-2-0 COMMAND_MODE=unix2003 DISPLAY=/tmp/launch-q5Y1id/org.x:0 HISTSIZE=4000 HOME=/Users/winstonlee LANG=en_US.UTF-8 LOGNAME=winstonlee OLDPWD=/Users/winstonlee PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin PWD=/Users/winstonlee/bh SHELL=/bin/bash SHLVL=1 SSH_AUTH_SOCK=/tmp/launch-WI9YBK/Listeners TERM=xterm-256color TERM_PROGRAM=Apple_Terminal TERM_PROGRAM_VERSION=303.2 TERM_SESSION_ID=3D7D5A54-96ED-4FD8-A9C2-C0EDFC140744 TMPDIR=/var/folders/4w/kshc1x5n0qjd0yhn8k4c8w2c0000gn/T/ USER=winstonlee _=/usr/bin/env __CF_USER_TEXT_ENCODING=0x1F5:0:0 ++++++++ Winstons-MacBook-Pro:bh winstonlee$ ---------- Post updated at 05:12 PM ---------- Previous update was at 05:11 PM ---------- duh, I guess it's bash ---------- Post updated at 05:12 PM ---------- Previous update was at 05:12 PM ---------- OS is Lion Last edited by methyl; 07-10-2012 at 05:48 PM.. Reason: code tags and highlight important line |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Try KSH maybe like this: Code:
# ksh # a="a b" # cd "$a" |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
In bash or ksh, quotes are so important when a string contains space characters: Code:
A="a b/x y" cd "$A" The double quotes are known as "soft quotes" because you can still do variable substitution. You cannot do variable subtitution within single quotes. Mini explanation. The cd command only expects one parameter. The default parameter separator is white space. Therefore without the double quotes it only read the a . I don't know what Shell @bartus11 has but it is certainly unusual. Last edited by methyl; 07-10-2012 at 05:50 PM.. Reason: change case of variable to make "a" unambiguous |
| The Following User Says Thank You to methyl For This Useful Post: | ||
wel51x (07-10-2012) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| perl newbie . &&..programming newbie (question 2) | xytiz | Shell Programming and Scripting | 1 | 05-07-2009 12:26 PM |
| UNIX newbie NEWBIE question! | Hanamachi | UNIX for Dummies Questions & Answers | 4 | 03-28-2009 04:10 PM |
| SED question: newbie here. | jigarlakhani | Shell Programming and Scripting | 2 | 07-01-2008 02:57 AM |
| Newbie question | Eduard | Programming | 1 | 06-09-2008 06:21 AM |
| Very new newbie question | Split100 | UNIX for Dummies Questions & Answers | 4 | 11-29-2005 03:49 PM |
|
|