Friday, 11 December 2015

Mask access_log.txt

Requirement is to extract access_log.txt in specific format, you can alter the text based on your requirement by additing extra $<position of word you are interested in>

Following command can be placed inside the file for example fal.sh

searchInFile=$(date "--date=${dataset_date} -1 day" +%d"/"%b"/"%Y|tr '[:lower:]' '[:upper:]')

createFile=$(date '+%d-%b-%Y')
 

grep ${searchInFile} access_log.txt|awk '{print $1,$6,$7}'|awk '{print "XXX.XXX.XXX",$2,$3}'>$createFile

grant execute priv on fal.sh, chmod +x fal.sh


No comments:

Post a Comment