쉘스크립트 뉴비는 웁니다 늅늅 이거 도와주시면 김태희 같은 여자친구 생깁니다
EVENT.LOG 텍스트 파일 (예시)
03/04 17:04:01 00000000 [code:8077] sensorindex:1, eventNum:1, index:46808, Desc:http sql injection keyword and 01, Log Occur:2015-03-04 17:03:59, Log Save:2015-03-04 17:03:59, Console curTime:2015-03-04 17:04:01
03/04 17:04:01 00000000 [code:8077] sensorindex:1, eventNum:1, index:46810, Desc:http sql injection keyword and 01, Log Occur:2015-03-04 17:04:00, Log Save:2015-03-04 17:04:00, Console curTime:2015-03-04 17:04:01
03/04 17:04:18 00000000 [code:4958] sensorindex:1, eventNum:1, index:46812, Desc:P2P BitTorrent - handshake, Log Occur:2015-03-04 17:04:16, Log Save:2015-03-04 17:04:16, Console curTime:2015-03-04 17:04:18
첨부한 EventLog.log를 이용하여 아래 “문제”를 쉘 스크립트로 작성 하라는 미션을 받았는데요
쉘 초보라서 해결을 못하고 있네요
문제) 아래 예시를 참조하여 Index 넘버, Desc, curTime:xxxx-xx-xx xx 별 카운트를 출력하시오
출력 예)
발생시간 | 인덱스번호 | 취약점 명 | 건수
2015-02-06 15 50012, land attack 100건
2015-02-06 15 43443 BitTorrent - handshake 100건
#!/bin/sh
EVENTLOG=./EventLog.log
echo "t------------------------------------------------------------------------"
echo "| 발생시간 | 인덱스번호 | 취약점 명 | 건수 | "
echo "t------------------------------------------------------------------------"
cat $EVENTLOG | while read Index Desc Console curTime
do
for arg in $(cat $EVENTLOG)
do
if [ "$Index" == "$arg" ]; then
Desc =`echo $ Console curTime| cut -d '.' -f1`;
echo "$INDEX";
fi
done
done
제가 만든 스크립트인데 실행이 되질 않네요 ...
이걸 참고하세요.
https://encodable.com/tech/blog/2008/12/17/Count_IP_Addresses_in_Access_Log_File_BASH_OneLiner
댓글 달기