From: Waider (waider at domain waider.ie)
Date: Thu 30 Aug 2001 - 22:32:02 IST
At Thursday, 30 August 2001, Conor Daly <conor.daly at domain met.ie> wrote:
>foreach word
> count=`grep -r -i word code | wc -l`
> if [ $count == '0' ]; then
> print word
> fi
>done
While this is fine, and no doubt smaller, faster scripts will be posted,
you're overlooking a simple and useful feature of 99% of standard unix
commands: the return code. grep returns an unsuccessful (non-zero)
result on failure, so you can feed it directly to if:
foreach word
if grep -r -i word code
..
You might also want to add -q to stop grep spewing out whatever it
finds.
Waider. Avoid needless redundant extra code.
--
waider at domain waider.ie / Yes, it /is/ very personal of me.
http://www.emailreader.co.uk/ - because firewalls suck.
================================================================
Access over 250 professionally developed online training courses
Purchase a 12 months membership online. Click below for details
http://training.beginners.co.uk/moreinfo/vid/eml
================================================================
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:11:54 GMT