I was looking around on the internet to find if there was already a way to time a certain part of an executable/script to see how long that part takes, but all that I find is more for outside the file. So I want to input a line that starts a timer and at the end of the part stops the timer and shows me the elapsed time, not the whole thing but just a part.
example:
#!/bin/sh
IPTABLES="/sbin/iptables"
BLOCKEDIPS_XS=/root/iptables/iptables/blockxs.zone
$IPTABLES -F
$IPTABLES -F INPUT
$IPTABLES -F OUTPUT
$IPTABLES --delete-chain
$IPTABLES -F FORWARD
$IPTABLES -F -t mangle
$IPTABLES -F -t nat
$IPTABLES -X
timer start
/bin/egrep -v "^#|^$" $BLOCKEDIPS_XS | while IFS= read -r ip
do
# Append everything to droplist
$IPTABLES -A droplist -i eth0 -s $ip -j LOG --log-prefix " Drop IP List blockxs "
$IPTABLES -A droplist -i eth0 -s $ip -j DROP
done <"$BLOCKEDIPS_XS"
timer stops, shows elapsed time