From owner-freebsd-questions@FreeBSD.ORG Tue Apr 11 20:16:08 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 A341F16A404 for ; Tue, 11 Apr 2006 20:16:08 +0000 (UTC) (envelope-from gs_stoller@juno.com) Received: from outbound-mail.nyc.untd.com (outbound-mail.nyc.untd.com [64.136.20.164]) by mx1.FreeBSD.org (Postfix) with SMTP id 8BB5643D73 for ; Tue, 11 Apr 2006 20:15:58 +0000 (GMT) (envelope-from gs_stoller@juno.com) Received: from webmail32.nyc.untd.com (webmail32.nyc.untd.com [10.141.27.172]) by smtpout04.nyc.untd.com with SMTP id AABCD2DVTACEWEM2 for (sender ); Tue, 11 Apr 2006 13:15:45 -0700 (PST) Received: (from gs_stoller@juno.com) by webmail32.nyc.untd.com (jqueuemail) id LMPYJ8A2; Tue, 11 Apr 2006 13:15:12 PDT Received: from [69.125.135.219] by webmail32.nyc.untd.com with HTTP: Tue, 11 Apr 2006 20:14:38 GMT X-Originating-IP: [69.125.135.219] Mime-Version: 1.0 From: "gs_stoller@juno.com" Date: Tue, 11 Apr 2006 20:14:38 GMT To: youshi10@u.washington.edu X-Mailer: Webmail Version 4.0 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-Type: text/plain Message-Id: <20060411.131512.22840.701172@webmail32.nyc.untd.com> X-ContentStamp: 15:7:2838578444 X-UNTD-OriginStamp: /s5f1SIGSI3+WdnoYQ8yRMdj5FlmvkF0uNlCepHxBJkWzAJCVMlo7g== X-UNTD-Peer-Info: 10.141.27.172|webmail32.nyc.untd.com|webmail32.nyc.untd.com|gs_stoller@juno.com 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 20:16:08 -0000 On Mon, 10 Apr 2006 22:30:32 -0700 Garrett Cooper wrote (my brief resp= onse follows all of his text): Just making a series of sh scripts to help automate updating and = whatnot of my fileserver (since I am trying to avoid having mistakes = occur with my system, and maybe help the community out a bit by = providing some decent means of updating their own machines), and 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=3D""; cd /usr/src; if [ -n `grep -e s/KERNCONF=3D/ /etc/make.conf` ] # want to look for = KERNCONF in /etc/make.conf then echo "enter in the kernel conf file full pathname:"; read KERNCONF; KC=3D"KERNCONF=3D$KERNCONF"; fi if [ -n `grep -e s/NO_CLEAN=3D*yes*/ /etc/make.conf` ] // want to look f= or = NO_CLEAN in /etc/make.conf -- is this really necessary? then cd sys; echo "cleaning sources" make clean; make cleandir; cd ..; fi echo "building kernel"; make buildkernel $KC; echo "installing kernel"; make installkernel $KC; echo "kernel compile complete. reboot to try new kernel"; TIA, -Garrett I see a problem in the line if [ -n `grep -e s/KERNCONF=3D/ /etc/make.conf` ] # want to look for = you should have double-quotes around the `grep ... conf` because it is likely to produce more than one token and so the [ -n ... ] statement violates the syntax (there should be exactly 1 t= oken between the -n and the ] , even no token there is an error, the = way that is handled is to quote it. I am writing this quickly without bringing up my FreeBSD system to che= ck it. Good luck. Another thing you can do to avoid quoting (and the long strings that may= result) is use the -c option of grep and check the number resulting= .