From owner-freebsd-questions@FreeBSD.ORG Tue Dec 30 16:39:07 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 864F516A4CE for ; Tue, 30 Dec 2003 16:39:07 -0800 (PST) Received: from lilzmailso01.liwest.at (lilzmailso01.liwest.at [212.33.55.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1537043D31 for ; Tue, 30 Dec 2003 16:39:06 -0800 (PST) (envelope-from dgw@liwest.at) Received: from cm58-27.liwest.at ([212.33.58.27]) by lilzmailso01.liwest.at with esmtp (Exim 4.24) id 1AbUO7-0005Ep-5q; Wed, 31 Dec 2003 01:39:03 +0100 From: Daniela To: "Rob" , Date: Wed, 31 Dec 2003 01:33:53 +0000 User-Agent: KMail/1.5.3 References: <200312290334.25341.dgw@liwest.at> <009801c3cdc9$88507280$a4b826cb@goo> In-Reply-To: <009801c3cdc9$88507280$a4b826cb@goo> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200312310133.53578.dgw@liwest.at> Subject: Re: Complex quoting task in tcsh X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Dec 2003 00:39:07 -0000 On Monday 29 December 2003 05:06, Rob wrote: > 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 Thanks a lot, that grep -q thing also works for tcsh. > For more complex work, perl or python are usually recommended. You can do lots of stuff with shellscript: look at user.berklix.org/~dgw > 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 Csh is not harmful at all -- it allows for great optimizing for certain tasks. > ----- Original Message ----- > From: "Daniela" > 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"