So i have this ssh cmd line: cat /var/log/httpd/error_log | grep ".ISC.SANS." | egrep -o '([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})' | awk '{print "iptables -I INPUT -s " $1 " -j DROP"}' | sort | uniq > drop.file For now it only search in oonly one file -> /var/log/httpd/error_log But how to rewrite it for to search for text in all files in a folder ?
Something like this would work if it was a directory full of error_logs for example: for i in /var/log/httpd/error_logs/*.log; do cat $i | grep ".ISC.SANS." | egrep -o '([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})' | awk '{print "iptables -I INPUT -s " $1 " -j DROP"}' | sort | uniq > drop.file That would do any file ending in .log, you could just to * for all files in that directory if all the files had the basic same structure that you were looking for.