Bash script that removes lines

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
I need a bash script that removes all the lines in a file that start with a specific string.

I want it for my httpd access log to remove all the local traffic (192.168.0.*)

Thanks.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
There's this neat script called "grep" ;)

mv /path/to/access_log /path/to/access_log.old
fgrep -v "^192.168.0." /path/to/access_log.old > /path/to/access_log

BTW, I don't know what the "proper" thing to do is, but generally I don't tamper with log files, I just make adjustments to things that process them to weed out things like myself accessing my own website or whatever.