#!/bin/sh # The extra credit script tofix the hacker attacks imge() { cat $1 | egrep -a '$2' > chunk awk -F'@#||@@#' '{print $3, $4}' chunk > dm awk -F: '{ newline=$2; split(newline,s,"[[:alpha:](*%]"); print s[0] + s[1] + s[2] + s[3] + s[4] + s[5] + s[6] + s[7] + s[8] + s[9] + s[10] + s[11] + s[12] + s[13] + s[14] + s[15] + s[16], ":" $1}' dm > unsrted cat unsrted | awk -F: '{ if ($2>max) max=$2 arr[$2]=$0 } END{ for(x=1;x<=max;x++) print arr[x] }' > srted } extact() { cat $infl | egrep -a '$regexp' > chunk awk -F'@#||@@#' '{print $3, $4}' chunk > dm awk -F: '{ newline=$2; split(newline,s,"[[:alpha:](*%]"); print s[0] + s[1] + s[ 2] + s[3] + s[4] + s[5] + s[6] + s[7] + s[8] + s[9] + s[10] + s[11] + s[12] + s[ 13] + s[14] + s[15] + s[16], ":" $1}' dm > unsrted cat unsrted | awk -F: '{ if ($2>max) max=$2 arr[$2]=$0 } END{ for(x=1;x<=max;x++) print arr[x] }' > srted } cln() { sed 's/@\{1,2\}#.*@#//g' $1 > $3 } cln() { sed 's/@\{1,2\}#.*@#//g' $1 > $outfl } if [ $1 ] then : else echo "Enter the input file name" read $infl echo $infl fi if [ $2 ] then : else echo "Enter your regular expression" read $regexp echo $regexp fi if [ $3 ] then : else echo "Enter the name of the output file" read $outfl echo $outfl fi if [ $1 ] && [ $2 ] && [ $3 ] then imge cln else extact climge fi