[oclug] sed (regexp) help needed

Ross Jordan rjordan at student.math.uwaterloo.ca
Thu Jul 24 09:59:19 EDT 2003


> 
> i'm trying to do what i thought was a pretty simple one-liner in sed:  parse a 
> log file and take out any references to my local ip so webalizer can run and 
> not show local results.  this is what i tried:
> 
>   sed -e s/^192\.168\.1\.2.*// mysite.com.log
> 
> but it doesn't work. instead, it deletes the content on the lines, but not the 
> newline (\n).  adding a "\n" to the end of the expression doesn't work 
> either.  anyone care to fill me in as to what i missed?

If you want to delete all lines containing your ip, just do:

egrep -v "192.168.1.2" < mysite.com.log > mysite.com.cleansed.log


-Ross



More information about the OCLUG mailing list