Date: Mon, 29 Dec 2003 15:36:35 +1030 From: "Rob" <listone@deathbeforedecaf.net> To: "Daniela" <dgw@liwest.at>, <questions@freebsd.org> Subject: Re: Complex quoting task in tcsh Message-ID: <009801c3cdc9$88507280$a4b826cb@goo> References: <200312290334.25341.dgw@liwest.at>
next in thread | previous in thread | raw e-mail | index | archive | help
Daniela, 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 commands: cat somefile | while read LINE ; do if echo "$LINE" | grep -q '^#' ; then # do something with $LINE fi done 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 file, put grep -v '^#' at the start of your pipeline. * Csh Programming Considered Harmful (1996) http://www.perl.com/pub/a/language/versus/csh.html ----- Original Message ----- From: "Daniela" <dgw@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 error. > Here's one: > if ($line =~ "#*") > Or is there another way to find out if the line starts with a hash mark? > > Regards, > Daniela > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?009801c3cdc9$88507280$a4b826cb>