Netshroud Posted October 21, 2010 Share Posted October 21, 2010 Hey all, I'm trying to convert a Squid3 log to mimic my Netgear WGR614v8 on stock firmware. So far what I have is as follows. (It may have a typo, I retyped it here instead of copying from a different machine) FILE=/var/log/squid3/access/log exec 0<$FILE while read line; do TIME=`echo $line | gawk '{ print strftime("%c", $1) }'` IP=`echo $line | awk '{ print $3 }'` DOMAIN=`echo $line | awk '{ print $7 }' | cut -d '/' -f 3 | sed 's/^www\.//'` echo [Site allowed: ${DOMAIN}] from source ${IP}, $TIME done Is there a more efficient way to do this? Quote Link to comment Share on other sites More sharing options...
Infiltrator Posted October 21, 2010 Share Posted October 21, 2010 I am not much of a programmer but you could implement some arrays and a for loop to make the code more efficient. Quote Link to comment Share on other sites More sharing options...
Netshroud Posted October 22, 2010 Author Share Posted October 22, 2010 I'd rather keep it in bash to keep it portable. Quote Link to comment Share on other sites More sharing options...
Infiltrator Posted October 22, 2010 Share Posted October 22, 2010 I'd rather keep it in bash to keep it portable. The code will still be portable. you are only change the structure of the code a bit to make it more efficient. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.