stuck on csh metacharacters

Hello,

I have a question, please (I am using tcsh).

I thought that if you enclose something in double quotes, then the shell won't interpret it. For example, when I do:

% echo "ls *"

I get

ls *

However, if I do:

% echo "!l"

I get

echo "ls -F"
ls -F

(my last command was ls -F

Why is this so? I thought that because I had enclosed !l inside double quotes, the shell would treat ! as text and not as a special character?

Please help!

Thanks.

A

Hmm... I honestly don't know what the metacharacters !| mean in tcsh. You could try escaping them with a backslash like:

% echo "\!\|"

Does that work?

Hi,

Thank you for your reply. Well, the metacharacter '!' is used to refer to the history of the commands.

So, for example, if you did ls -a, then followed it by rm *, then did echo $PATH, then !l (!-el) would be the same as the last command beginniing with "el" i.e. ls -a, !r would be rm * and !e would be echo $PATH.

I just don't know why echo "!l" is interpreting !l as a shell command!!! Surely it shouldn't when I double quote it.
Yes, escaping it with a backslash DOES work (i.e. "\!l" does work), but I don't see why we have to backquote ! when it is already is double quote! After all, we can do echo "ls ", and don't have to do echo "ls \".

I actually found out the answer to my own post, so am posting it here in case someone has the same problem.

In C shell, everything enclosed inside double quotes is treated as text, apart from !, $ and `