|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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/ { 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 |
|
![]() |
| Outils de la discussion | |
|
|