Remove entries from Apache web server access_log file

Remove entries from Apache web server access_log file

Post by Just » Tue, 08 Apr 2003 22:48:43



How do you delete your local IP address
entries from the Apache web server access
log file without removing the valid entries.
Need correct valid data for Web analysis

Not sure if you use sed (Stream Editor)
Any help much appreciated
Regards

Justin Miles

 
 
 

Remove entries from Apache web server access_log file

Post by Sybren Stuve » Tue, 08 Apr 2003 23:31:12


Justin enlightened us with:

Quote:> How do you delete your local IP address entries from the Apache web
> server access log file without removing the valid entries.

man grep.

For instance:

grep -v '192.168.0.' < logfile

Sybren
--
| Somebody ought to cross ball point pens with coat hangers so that |
| the pens will multiply instead of disappear.                      |
\-------------------------------------------------------------------/
If you have to use Outlook, fix it: http://jump.to/oe-quotefix

 
 
 

Remove entries from Apache web server access_log file

Post by Davi » Wed, 09 Apr 2003 03:00:16



> How do you delete your local IP address entries from the
> Apache web server access log file without removing the valid
> entries. Need correct valid data for Web analysis

> Not sure if you use sed (Stream Editor) Any help much
> appreciated Regards

> Justin Miles

If you want to remove the entries from the log file you can do it
with this script and the command below to specify the text you
wish to remove. This removes the line containing the text you
specify.
--------Script below----
#!/bin/sh
#  Name it what you want maybe "clearlogtext"
# Clears entries from log files.
#
if [ $# != 2 ] ; then
    echo "syntax: $0 logfile text"
else
    awk !/$2/{print} $1 > t;>$1;cat t > $1; rm t
fi
--------------------------------------------------------

Then run the following command to clear the text. Replace
"logfile" in the line below with the file you want to run it on.

clearlogtext  /var/log/logfile  "192.168.1.1"

--
Confucius:  He who play in root, eventually kill tree.
Registered with the Linux Counter.  http://counter.li.org
Slackware 9.0 Kernel 2.4.20 i686 (GCC) 3.2.2
Uptime: 2 days, 11:36, 1 user, load average: 1.01, 1.08, 1.13