YANQ (Yet Another Newbie Question)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers YANQ (Yet Another Newbie Question)
# 1  
Old 07-10-2012
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.Smilie

Any help would be graciously accepted.
# 2  
Old 07-10-2012
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?
This User Gave Thanks to bartus11 For This Post:
# 3  
Old 07-10-2012
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 03:50 AM.. Reason: please ue code tags
# 4  
Old 07-10-2012
Hmmm... OSX? What shell are you using?
This User Gave Thanks to bartus11 For This Post:
# 5  
Old 07-10-2012
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 06:48 PM.. Reason: code tags and highlight important line
# 6  
Old 07-10-2012
Try KSH maybe like this:
Code:
# ksh
# a="a b"
# cd "$a"

# 7  
Old 07-10-2012
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 06:50 PM.. Reason: change case of variable to make "a" unambiguous
This User Gave Thanks to methyl For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

newbie question

Hi all, I am sure this is very simple but I cant quite get it. I am trying to search textfile1.txt for a string then take the results of the search and append the result to textfile3.txt So far I have used $ find file1.txt -exec grep "string i am looking for" '{}' \; -print this... (2 Replies)
Discussion started by: radgator
2 Replies

2. Shell Programming and Scripting

perl newbie . &&..programming newbie (question 2)

Hello everyone, I am having to do a lot of perl scripting these days and I am learning a lot. I have this problem I want to move files from a folder and all its sub folders to one parent folder, they are all .gz files.. there is folder1\folder2\*.gz and there are about 50 folders... (1 Reply)
Discussion started by: xytiz
1 Replies

3. UNIX for Dummies Questions & Answers

UNIX newbie NEWBIE question!

Hello everyone, Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware. I hope I am not missing anything! :p (4 Replies)
Discussion started by: Hanamachi
4 Replies

4. Programming

Newbie question

Dear all, I have a question related to parallel programing and if you can give me some hints on how to deal with it, it would be really great. I would like to run a small application on a supercompter of 128 CPUs. Unfortunately, on this machine only jobs which require 32 CPUs are allowed to... (1 Reply)
Discussion started by: Eduard
1 Replies

5. UNIX for Dummies Questions & Answers

Newbie question?

What is the best way to learn UNIX on the web, with out buying books? any link would be much help. Thank you in advance, L (1 Reply)
Discussion started by: lsoria1
1 Replies

6. UNIX for Dummies Questions & Answers

newbie question

I am taking a db classes toward oracle 10g. I am taking unix as well . I need to know what is the best option for os . should I use linux fedora. or get a sun box and start learning from there. Thanks (6 Replies)
Discussion started by: xzyan
6 Replies

7. UNIX for Dummies Questions & Answers

Very new newbie question

sorry if im not asking inthe right spot but, how do you turn the beeping off every time you hit a key onthe keyboard. I tried the click -n but it told me it didnt recognize click any help would be greatly appreciated ( the beeping is not going over well in the surrounding cubicles) thank you... (4 Replies)
Discussion started by: Split100
4 Replies

8. Shell Programming and Scripting

Newbie question

Hello, I have text file while looks this test1 test2 test3 test4 test5 test6 and if I want to parse it and make new file which would like this test1 test2 test3 test4 test5 test6 How can I do this in korn shell script Thanks (9 Replies)
Discussion started by: peeyush_23
9 Replies

9. UNIX for Dummies Questions & Answers

Newbie Question

Hi, I have a file, that is delimited by :: and the purpose of this file is none of your business. ;) There are about 65000 lines in this file, and there are lines that I would like to remove. About 45000 of them. Is there some sort of commands that I can run, to remove word(s) from this... (4 Replies)
Discussion started by: th3gh05t
4 Replies

10. UNIX for Dummies Questions & Answers

newbie question

hi im thinking of getting unix but i have no idea where to start I know that its an OS similar to linux but what hardware does in run on? i've heard of solaris but im not quit sure what it is thankxs (3 Replies)
Discussion started by: ninja
3 Replies
Login or Register to Ask a Question