shell安全脚本

1、检索access.log日志并按ip访问次数进行排序,显示前10

cat access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head -n 10

2、搜索当前目录下包含指定字段的文件(包括子目录)

find ./ -type f -name "*" |xargs grep "1.4.10.18"

grep -rn 'nikto-test' . --include=*      跟上面类似,不过可以显示具体在哪行

  

3、只查看配置文件中未被注释的有效配置行

#有空白行
grep -v "^#" denyhosts.conf

#无空白行
cat denyhosts.conf | grep "^s*[^# 	].*$"
sed '/ *#/d; /^ *$/d' denyhosts.conf
egrep -v "^#|^$" denyhosts.conf

奶奶问孙子:4+1等于几 孙子说:等于6-1。 奶奶说:你明明知道答案,为什么不说? 孙子说:年轻人不讲5的……..
原文地址:https://www.cnblogs.com/jasy/p/15159150.html