Aqui está uma análise estática para o seu script de shell:
1 #!/bin/bash
2
3 a='netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | grep -v '1 ' | grep -v '2 ' | grep -v '3 ' | grep -v '1.1.1.1' | grep -v '1.2.2.2' | grep -v '127.0.0.1' | grep -v '127.0.1.''
^––SC2006 Use $(..) instead of legacy '..'.
4 ip='netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | grep -v '1 ' | grep -v '2 ' | grep -v '3 ' | grep -v '1.1.1.1' | grep -v '1.2.2.2' | grep -v '127.0.0.1' | grep -v '127.0.1.' | awk '{print$2}' | tail -1'
^––SC2034 ip appears unused. Verify it or export it.
^––SC2006 Use $(..) instead of legacy '..'.
5 d='date'
^––SC2006 Use $(..) instead of legacy '..'.
6 p='ps ax | grep $IP | grep -v grep | grep -v /usr/sbin | awk '{print $1}''
^––SC2006 Use $(..) instead of legacy '..'.
^––SC2009 Consider using pgrep instead of grepping ps output.
^––SC2086 Double quote to prevent globbing and word splitting.
7 k='kill -9 $p'
^––SC2006 Use $(..) instead of legacy '..'.
^––SC2086 Double quote to prevent globbing and word splitting.
8 if [ -n "$a" ]
9 then echo -e "file exists\n IPs copied in .../log folder" && echo -e "\n Current date: $d \n$a" >> /var/log/offendersips.log
10 else
11 echo "file empty, no abuse"
12 fi
13 if [ -n "$a" ]
14 then echo "$k"
15 else
16 echo "file empty, no abuse"
17 fi