Date: Tue, 11 Apr 2006 20:14:38 GMT From: "gs_stoller@juno.com" <gs_stoller@juno.com> To: youshi10@u.washington.edu Cc: freebsd-questions@freebsd.org Subject: Re: Need /bin/sh script help Message-ID: <20060411.131512.22840.701172@webmail32.nyc.untd.com>
next in thread | raw e-mail | index | archive | help
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=
.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060411.131512.22840.701172>
