MACSCRPT Archives

December 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Lively <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sun, 31 Dec 2006 11:31:18 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
On Dec 31, 2006, at 4:45 AM, Olof Svensson wrote:

> Hej Mark and a Happy New Year to you
>
> English is not my first language. I try to keep it short but I dont  
> whant to sound rude.
>
> I have:
> OS X 10.3.9 and Bash as shell.
> a .bash_profile file with < PATH=$PATH":/Users/neko/bin" >
> in my bin folder: a script:
> 	
> 	#!/bin/bash
>
> 	alog="/private/var/log/httpd/access_log"
> 	ip1="127.0.0.1"
> 	ip2="192.168.0.101"
>
> 	if grep -v $ip1 $alog || grep -v $ip2 $alog
> 	then
> 		...
> 	fi
> ___________ END of script ________________
>
> I try to open my 'access_log' and filter away (!) two ip-numbers,  
> and pipe the result to 'BBEdit'
>
> Problem
> 	if grep -v $ip1 $alog || grep -v $ip2 $alog	 (dont work) but
> 		 if grep -v $ip1 $alog	(work)
>

What I think you want is

if grep -v $ip1 $alog | grep -v $ip2

What you have searches the file and if there is a line that is  
missing the first ip address it returns true and since || returns  
true before evaluating all of the parameters you merely get a list  
from the first.

| is called the pipe operator and it takes the output of one command  
and feeds it into the next as an input.  Notice that I didn't have a  
file in the second grep.



> and how do I the pipe the result to a new BBEdit-file
>
> If you or sombody else have an answer PLEASE CC me at  
> [log in to unmask]
>
>
> --
> Olof Svensson
>

ATOM RSS1 RSS2