Need /bin/sh script help
Parv
parv at pair.com
Tue Apr 11 17:46:47 UTC 2006
in message <443B3EF8.3020308 at 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
--
More information about the freebsd-questions
mailing list