System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I display a directory beginning with &

 
SOLVED
Go to solution
Marshmellow
Advisor

How can I display a directory beginning with &

I Have the following directory:-

drwxrwxr-x 2 Tech UserGT 794624 Jul 27 12:21 &KLCTEST&

If I just type cd &KLCTEST&
I get directory not found?

How can I go into this directory please?

Thanks,
7 REPLIES
Matti_Kurkela
Honored Contributor
Solution

Re: How can I display a directory beginning with &

One way is to escape the problem characters:

cd \&KLCTEST\&
or
cd '&KLCTEST&'

Another way is to use wildcards:

cd ?KLCTEST?

The question mark is the wildcard for "insert any one character here". The shell will expand the wildcards before executing the command. If there is only one matching name, the command will run successfully.

MK
MK
Prashantj
Valued Contributor

Re: How can I display a directory beginning with &

Hi Marshmellow,

Try below one.
cd "&KLCTEST&"

Hope this will help

Prashant
Good judgment comes from experience and experience comes from bad judgment.
Marshmellow
Advisor

Re: How can I display a directory beginning with &

Thanks that sorted it out on the command line.

I was actually troubleshooting my script when I came across the reported error.

dir="/home/users/brown/\&KLCTEST\&"

How can I make this assignment work?

Prashantj
Valued Contributor

Re: How can I display a directory beginning with &

Hi Marshmellow,

now try
dir=="/home/users/brown/&KLCTEST&"

Heope this will work

Prashant.
Good judgment comes from experience and experience comes from bad judgment.
Prashantj
Valued Contributor

Re: How can I display a directory beginning with &

Hi Marshmellow,

Please ignoe the previous one, having typo error.
try below one.
dir="/home/users/brown/&KLCTEST&"

Prashant
Good judgment comes from experience and experience comes from bad judgment.
Marshmellow
Advisor

Re: How can I display a directory beginning with &

thanks guys... I'm sorted!
Marshmellow
Advisor

Re: How can I display a directory beginning with &

thanks