#!/bin/bash
cd /usr/local/logstash/Nginxlog
[ -f num.txt ] || count=0
[ -f num.txt ] && count=cat num.txt
ncount=wc -l /var/log/Nginx/access-app.log | awk '{print $1}'
echo $ncount > num.txt
for ((i=$count+1;i<=$ncount;i++))
do
num=$[i]p
log=sed -n $num /var/log/Nginx/access-app.log
tapi=echo $log | awk '{print $9}' | awk -NF ? '{print $1}'
oapi=echo $tapi | sed 's?//?/?'
if egrep "($oapi)$" api.txt > /dev/null 2>&1; then napi=`egrep "($oapi)$" api.txt`echo $log | sed s?$tapi?$napi?g >> access-app-elk.logelseecho $log >> access-app-elk.logfidone