stuck on csh metacharacters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting stuck on csh metacharacters
# 1  
Old 10-31-2006
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
# 2  
Old 10-31-2006
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?
# 3  
Old 10-31-2006
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 \*".
# 4  
Old 11-08-2006
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 `
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash Vs. Bourne REGEX: metacharacters escaping

I am currently reading a very old reference from O'Reilly: Sed and Awk 2nd Edition reprinted in 2000. So far, it's a solid read and still very relevant. I'd highly recommend this to anyone. The only problem I have with this book is that I had to resort to bourne shell to get my examples to work... (3 Replies)
Discussion started by: ConcealedKnight
3 Replies

2. UNIX for Dummies Questions & Answers

display types of files using metacharacters

1) I want to display all the files in a directory that start with the word chapter, are followed by a digit 1,2,6,8, or 9 and end with .eps or .prn so I came up with this file ~/temp/chapter.eps ~/temp/chapter.prn but is there a better way, i.e. combining both file types into the command? ... (2 Replies)
Discussion started by: dunsta
2 Replies

3. Shell Programming and Scripting

metacharacters separation

I have prepared a script to submit a string in a txt file. However there are somethings that I have to check before submitting the string in the txt file. One of those checks is to determine whether the string entered contains any metacharacters. I have tried sth like; echo "string" | grep -v ... (3 Replies)
Discussion started by: ozum
3 Replies

4. UNIX for Dummies Questions & Answers

The ll command + metacharacters

Hello. I am learning how to use Unix through an online course. Unfortunately the text that we use isn't very good, so I could use some help with a pretty basic question. Use metacharacters and the ll command to list all filenames under the datafiles directory that contain a dot "." with the... (2 Replies)
Discussion started by: feverdream
2 Replies

5. Shell Programming and Scripting

use metacharacters to extract date

If I have a filename as filename.txt.20090807 and I use for FILE in `find . -name "filename*" -type f` do my_time=${FILE#./filename.txt.} I get my output as 20090807 However if my filename is filename.Y20090807.txt Is there a way I can use metacharacters in my... (3 Replies)
Discussion started by: RubinPat
3 Replies

6. Shell Programming and Scripting

passing string which includes metacharacters

I'm trying to create a bash script that takes a URL as one of its arguments like this: ./script.sh http://url.cfm?asdf&asdf=234 variable=$1 echo $variable I'm having trouble storing the URL because it contains the meta character "&" which is being interpreted... thus when I run the... (4 Replies)
Discussion started by: kds1398
4 Replies

7. Shell Programming and Scripting

Metacharacters analysis

:confused:Hi , Can someone please advise what is the meaning of metacharacters in below code? a_PROCESS=${0##*/} a_DPFX=${a_PROCESS%.*} a_LPFX="a_DPFX : $$ : " a_UPFX="Usage: $a_PROCESS" Regards, gehlnar (3 Replies)
Discussion started by: gehlnar
3 Replies

8. Shell Programming and Scripting

csh failing to call an 2 embedded csh script

I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them) Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Discussion started by: pollsizer
1 Replies

9. UNIX for Dummies Questions & Answers

Metacharacters

I want to display an asterisk to the screen as part of a string. I know how to use the Backslash to escape it's value. But how do I display it without showing the Backslash? (1 Reply)
Discussion started by: regencyabs
1 Replies

10. Shell Programming and Scripting

Using metacharacters in loops

Is there a way to use metacharacters in a loop or in an if. I want to allow a user to enter Y, y, Yes, yes, Yah, etc... in a loop I tried: read response while *" ] do........ and while *" ] do ......... this works for grep or egrep but not in loops Why?????? (4 Replies)
Discussion started by: jrdnoland1
4 Replies
Login or Register to Ask a Question