Mime-Version: |
1.0 (Apple Message framework v752.2) |
Sender: |
|
Date: |
Sun, 31 Dec 2006 11:31:18 -0500 |
Reply-To: |
|
Subject: |
|
From: |
|
Content-Transfer-Encoding: |
7bit |
In-Reply-To: |
|
Content-Type: |
text/plain; charset=US-ASCII; delsp=yes; format=flowed |
Comments: |
|
Parts/Attachments: |
|
|
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
>
|
|
|