文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>本人因为最近过得过于苦闷忍不住冲动写了个脚本

本人因为最近过得过于苦闷忍不住冲动写了个脚本

时间:2006-12-25  来源:kingliyou

首先,助各位朋友圣诞节快乐,虽说是老外们的节日不过最近几年愈来愈有喧宾夺主的意味了........

其次,我介绍一下这个脚本的功能:

1. 和那个Python脚本不同的是,这个脚本偏向于文件操作; 文档中(log file)的过滤, 关键词的提取.

2. 可以给文档中出现频率高的关键句计数.

#!/bin/bash


# Author: kingliyou


# Due Date 23/11/05


# Version 1.0


# Description: A simple script using 'sed' 'awk' 'grep' as filters


# to re-allocate the text files


echo 'IP Address Filter'

echo

echo "Please enter any key to continue"

   finish=no

      while [ $finish = "no" ]; do

       echo

       echo IP ADDRESS FILTER MENU

       echo ======================

       echo

       echo "Enter For Options"

       echo "------------------------"

       echo " 1 Attemp Times"

       echo " 2 Incoming IP Address List"

       echo " 3 Sorted Address"

       echo " Q Quit Log"

       echo

       echo "Please Select Option:"

        

          read Option

            cat mail.log | grep "rejected" > rejected

              if [ $Option = "1" ]; then

      

                echo This is a list of "rejected" mail attempt times:

                echo

   

                 cat rejected | awk '{ print $5 }' | sed -e 's/sm-mta//g' | sed -e 's/://g' | sed -e 's/\[//g ' \

                 | sed '1, $s/]//g' | sort -b -nr | less

  

              elif [ $Option = "2" ]; then

                echo Incoming IP Address List:

                echo

                echo Press 'Y' to get the result:

                echo

                   read ans

                      if [ "$ans" = "Y" -o "$ans" = "y" ]; then

        

                        cat rejected | awk -F "from" '{ print $2 }' | awk '{ print $1 }' | less

                      else

                        echo ' Permission Denied....... '

                        echo

                      fi

              elif [ $Option = "3" ]; then

                echo Press "Y" to get Sorting List:

                echo

                   read ans

                      if [ "$ans" = "Y" -o "$ans" = "y" ]; then

        

                        cat rejected | awk -F "from" '{ print $2 }' | awk '{ print $1 }' | less > temp1

                        cat temp1 | sort | uniq -c | tr -d .

                        cat temp1 | sort | uniq -c | tr . ' ' > temp2

                        cat temp2 | awk '{ print $2, $3, $4, $5 }' > temp3

                        cat temp2 | awk '{ print $1 }' > temp5

                        cat temp3 | sort -k1n -k2n -k3n -k4n > temp4

                        cat temp4 | tr ' ' . > temp6

                        paste temp5 temp6 | less

                      else

                        echo ' IP Address is not sorted......... '

                        echo

                        echo ' Press any key to continue........ '

                      fi

              elif [ $Option = "Q" -o $Option = "q" ]; then

            

   finish=yes

          

          else

             echo "Invalid Choice. Try Again Please"

             echo

          fi

             echo

             echo Press 'Return' to QUIT

         read dummy

done

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载