Stripping IP Addresses from Apache Logs

Yesterday I had to send off some apache logs to someone so they could verify dates that certain files were downloaded.

 

Since this person was not the owner of the website, just the owner of the files, I needed to anonymize the data quickly and efficiently.

 

Since browser fingerprinting isn't something I am terribly concerned about currently, I decided that simply removing the IP address of the requester from the logs would be sufficient.

 

Luckily this was an extremely simple matter:

cat web.log | awk '{$1=$2=$3=""}1' > web-no-ip.log

 

That's it! That removed the first three fields from the apache logs. The first field contained the IP address and on my server the second two were blank so I just removed them as well. If the data in the second two fields is something you want to keep, just modify the command to:

cat web.log | awk '{$1=""}1' > web-no-ip.log

 



Back to Article Index

blog comments powered by Disqus