PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > 'tail -f' to multiple greps, redirect output...
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

'tail -f' to multiple greps, redirect output...

Réponse
 
LinkBack Outils de la discussion
Vieux 05/12/2006, 18h21   #1
nortonloaf@comcast.net
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 'tail -f' to multiple greps, redirect output...

I'm trying to tail a log file, and pull out meaningful lines to save in
a different file. This command does what I want:

tail -f log.file | grep '^\|' | grep "stockA\|stockB\|stockC\|stockD" |
grep -v "DEBUG\|INFO\|WARN"

but when I add to the end of it: >> goodlog.file

i find that no data is written to goodlog.file.

Any would be greatly appreciated.

  Réponse avec citation
Vieux 05/12/2006, 19h17   #2
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'tail -f' to multiple greps, redirect output...

On 5 Dec 2006 10:21:48 -0800, nortonloaf@comcast.net
<nortonloaf@comcast.net> wrote:
> I'm trying to tail a log file, and pull out meaningful lines to save in
> a different file. This command does what I want:
>
> tail -f log.file | grep '^\|' | grep "stockA\|stockB\|stockC\|stockD" |
> grep -v "DEBUG\|INFO\|WARN"
>
> but when I add to the end of it: >> goodlog.file
>
> i find that no data is written to goodlog.file.
>
> Any would be greatly appreciated.
>

Maybe the data is being buffered and will be written to the file when
the buffer is full.

--
I respect faith, but doubt is what gives you an education.
-- Wilson Mizner
  Réponse avec citation
Vieux 05/12/2006, 19h58   #3
nortonloaf@comcast.net
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'tail -f' to multiple greps, redirect output...


Bill Marcum wrote:

> Maybe the data is being buffered and will be written to the file when
> the buffer is full.


Hi,

Thanks for the response, I appreciate it.

Do you know if it is possible to force it to write to the file right
away?

  Réponse avec citation
Vieux 05/12/2006, 20h23   #4
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: 'tail -f' to multiple greps, redirect output...

2006-12-5, 11:58(-08), nortonloaf@comcast.net:
>
> Bill Marcum wrote:
>
>> Maybe the data is being buffered and will be written to the file when
>> the buffer is full.

>
> Hi,
>
> Thanks for the response, I appreciate it.
>
> Do you know if it is possible to force it to write to the file right
> away?


Try:

tail -f log.file |
gawk '
/stock[A-D]/ && ! /DEBUG|INFO|WARN/ {
print
fflush()
}' > file

If you don't have gawk, use awk instead and system("") instead
of fflush().

If your grep is the GNU grep (as would suggest your "\|"), you
can use the --line-buffered option.

--
Stéphane
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h38.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10097 seconds with 12 queries