Gentoo Archives: gentoo-user

From: Neil Bothwick <neil@××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] OT - Question about conditionals and bash scripting
Date: Thu, 12 Oct 2006 21:22:23
Message-Id: 20061012221742.64b3e79d@hactar.digimed.co.uk
In Reply to: [gentoo-user] OT - Question about conditionals and bash scripting by Michael Sullivan
1 On Thu, 12 Oct 2006 15:41:12 -0500, Michael Sullivan wrote:
2
3 > while read LINE
4 > do
5 > whois $LINE | grep 'abuse' &> /dev/null
6 > if $? != 0; then
7 > echo "$LINE" >> noabuse.txt
8 > fi
9 > done < iplist
10 >
11 > I'm getting "command not found" on the if line.
12
13 The if line should be "if [ $? -ne 0 ]; then"
14
15 Or you can put grep directly into the if statement, since you are only
16 testing its result anyway
17
18 if whois $LINE | grep -q abuse; then
19
20
21 --
22 Neil Bothwick
23
24 There are some micro-organisms that exhibit characteristics of both
25 plants and animals. When exposed to light they undergo photosynthesis;
26 and when the lights go out, they turn into animals. But then again,
27 don't we all?

Attachments

File name MIME type
signature.asc application/pgp-signature