Discussion Locked

Using '&' in file names

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

When we use '&' in file names when the file name goes to the bourne shell the '&' changes to '&" even after we use an escape sequence.

Could anyone help us here to get around the problem so that we can store the file name with '&' as it is?

6 replies

by gary_w

Ok, if I understand this, you want to include the single quote with the ampersand character. This works:

$ who > "test'&'xyz"
$ ls -l
-rw-r--r-- 1 XXXX XXXX 271 Jul 31 14:11 test'&'xyz

Blue Skies,
Gary

P.S. Read up on quotes in the shell man page to see how the shell interprets them.

by gary_w

By the way, you'll always have to enclose the file name in quotes.

$ cat "test'&'xyz"

Why on earth would you want this extra hassle?

by ann777

If single quotes do not work, then try double quotes. And if that does not work, then try two ampersands.

This discussion is closed to new replies.