![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help! How to compare two lines in a file | sabertooth2000 | Shell Programming and Scripting | 3 | 04-23-2008 01:26 AM |
| compare files by lines and columns | giviut | Shell Programming and Scripting | 4 | 01-17-2008 06:00 AM |
| How to execute the rest of the code after commenting multiple lines? | Yamini Thoppen | Shell Programming and Scripting | 12 | 01-02-2008 12:50 PM |
| Trying to compare lines in 2 files | brdholman | Shell Programming and Scripting | 2 | 09-20-2007 08:46 AM |
| How can I get an if statement to execute based on number of lines in a file? | LordJezo | Shell Programming and Scripting | 6 | 05-14-2004 11:50 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Compare lines and execute
Greetings,
I'm new to scripting and need a little help. I have a NAS server and want to make a script that bans IP if they fail login several times. The problem is that I dont know how to compare the IP's in the file. If they exist more than 3 times do .... #!/bin/sh set -x X=4 rm /home/banip/output touch /home/banip/output.1 grep "Invalid user root" /var/log/messages|cut -c 68-79 > /home/banip/output.1 #If the same entry is gathered in the file more than x times A=`cat /home/banip/ban_this_ip|wc -l` echo $A if [ "$A" -ge "$X" ] then cat $ theIP >> /etc/config/ipsec_deny.conf else echo "Nothing to worry about" fi ######################################### #Output.1 now contains: 218.22.9.118 218.22.9.118 218.22.9.118 So if the above scenario where the same IP exists more 3 times (is unique) then insert this ip into /etc/config/ipsec_deny.conf |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|