From owner-freebsd-questions@FreeBSD.ORG Tue Apr 11 17:46:47 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org 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 D6D5D16A404 for ; Tue, 11 Apr 2006 17:46:47 +0000 (UTC) (envelope-from parv@pair.com) Received: from mta13.adelphia.net (mta13.adelphia.net [68.168.78.44]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4157243D53 for ; Tue, 11 Apr 2006 17:46:46 +0000 (GMT) (envelope-from parv@pair.com) Received: from default.chvlva.adelphia.net ([69.160.66.115]) by mta13.adelphia.net (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP id <20060411174646.SMQO27529.mta13.adelphia.net@default.chvlva.adelphia.net>; Tue, 11 Apr 2006 13:46:46 -0400 Received: by default.chvlva.adelphia.net (Postfix, from userid 1000) id 24D67B6B4; Tue, 11 Apr 2006 02:03:05 -0400 (EDT) Date: Tue, 11 Apr 2006 02:03:05 -0400 From: Parv To: Garrett Cooper Message-ID: <20060411060305.GA2175@holestein.holy.cow> Mail-Followup-To: Garrett Cooper , freebsd-questions@freebsd.org References: <443B3EF8.3020308@u.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <443B3EF8.3020308@u.washington.edu> Cc: freebsd-questions@freebsd.org Subject: Re: Need /bin/sh script help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2006 17:46:47 -0000 in message <443B3EF8.3020308@u.washington.edu>, wrote Garrett Cooper thusly... > > I was wondering if anyone could help me out with the following > script I've developing (the grep if statements are incorrect..): > > #!/bin/sh > # > > KC=""; > > cd /usr/src; > > if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for Well, you did not write what exactly is the problem, as executing the above works as expected. Why do have 'KERNCONF' surrounded by 's/' & '/'? In any case, there is not need to see if the returned string length is nonzero. Just use the grep return code & send the all the output to /dev/null ... if grep -e '^KERNCONF=' /etc/make.conf >/dev/null 2>&1 then ... fi ... or you could also use '-q' and/or '-s' grep options instead of sending output to /dev/null. (I personally would do a bit more strict check to see $KERNCONF is set to value containing characters meeting some criteria, say '\<[-._[:alnum:]]+\>'.) > KERNCONF in /etc/make.conf > then > echo "enter in the kernel conf file full pathname:"; I did not know one can specify the kernel configuration path, not just the basename. > read KERNCONF; > KC="KERNCONF=$KERNCONF"; > fi > > if [ -n `grep -e s/NO_CLEAN=*yes*/ /etc/make.conf` ] // want to look for ^^ ^^ Wrong kind of comment character. See above comments about grep(1) usage. - Parv --