Complex quoting task in tcsh
listone at deathbeforedecaf.net
Sun Dec 28 21:06:45 PST 2003
This isn't the answer you would like, but tcsh is generally considered a
bad language for writing scripts*. It's an excellent command-line shell,
but scripts are not its strong point.
One reason is the one you've just run into - quoting is a little flakey,
especially when you try to do something tricky.
For 'basic' scripts, either sh(1) or ksh(1) is usually the way to go. As
an example, here's your line-checking question, using sh and FreeBSD
cat somefile | while read LINE ; do
if echo "$LINE" | grep -q '^#' ; then
# do something with $LINE
For more complex work, perl or python are usually recommended.
On the other hand, if you just want to filter the comments out of a
grep -v '^#'
at the start of your pipeline.
* Csh Programming Considered Harmful (1996)
----- Original Message -----
From: "Daniela" <dgw at liwest.at>
Subject: Complex quoting task in tcsh
> I'm writing a tcsh script and I can't figure out how to escape that #.
> I tried all possible variations, and it always says I have a syntax
> Here's one:
> if ($line =~ "#*")
> Or is there another way to find out if the line starts with a hash
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to
"freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions