I have a list of IP addresses saved to a text file. Each of these IP
addresses exists in one or more other files, and I need to find those
files and so that I can automatically delete them with my script.
Here's the script:
#!/bin/bash
while read LINE
do
echo "Proccessing $LINE..."
for x in *,*; do
echo "Filename: $x"
cat $x | grep '$LINE'
if [ $? -eq 0 ]; then
echo "Filename is $x."
echo "IP is $LINE."
echo
fi
done
done < noabuse.txt
An example of one of the filenames is 1160386752.001262.mbox:2,S .
The first IP address in noabuse.txt is 07.26.20.24
This is the problem; when my script is running, it does not return the
correct result. For example, given the command and output:
[EMAIL PROTECTED] ~/.maildir/.SPAM/cur $ grep '07.26.20.24' *,*
1160386752.001262.mbox:2,S:Received: from 0zfop86845qtdbbu.tw
([07.26.20.24]) by tm.net.my with Microsoft SMTPSVC(5.0.2195.5534);
[EMAIL PROTECTED] ~/.maildir/.SPAM/cur $
However, when my script is running (I have echo statements instead of
rm statements because I want to make sure it works before anything
gets deleted), when it gets to 1160386752.001262.mbox:2,S it should
say "Filename is 1160386752.001262.mbox:2,S" and then "IP is
07.26.20.24". Instead it goes on past:
.
.
.
Filename: 1160386752.001256.mbox:2,
Filename: 1160386752.001257.mbox:2,
Filename: 1160386752.001258.mbox:2,S
Filename: 1160386752.001259.mbox:2,
Filename: 1160386752.001260.mbox:2,
Filename: 1160386752.001261.mbox:2,
Filename: 1160386752.001262.mbox:2,S
Filename: 1160386752.001263.mbox:2,S
Filename: 1160386752.001264.mbox:2,S
.
.
.
Why isn't this working? Am I doing something wrong? Is there an
easier way to extract the filename from grep?
To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be
removed.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/LINUX_Newbies/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/LINUX_Newbies/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/