Toon posts:

hoe regels vergelijken in bash ofzo

Pagina: 1
Acties:
  • 156 views sinds 30-01-2008
  • Reageer

Verwijderd

Topicstarter
Hallo daar,

ik zit te hopen op wat tips hier hoe dit aan te pakken:

Ik heb een logfile die per minuut wordt aangemaakt (met snmp traps).

Nu zitten er in zo een pagina veel dezelfde regels. Ik wil nu op een scherm toveren of in een file de foutmeldingen, maar als er meer regels hetzelfde zijn die maar een keer laten zien met een tellertje hoeveel keer hij is geweest.

Hoe pak ik dat aan. Moet ik elke regel in een variabele stoppen en deze dan vergelijken met alle andere regels en zo door?

Wie heeft er wat tips wat handig is. |Gaat dat in bash of moet ik toch naar perl ofzo?

groet

hc

Verwijderd

hermanb: Ik heb een logfile die per minuut wordt aangemaakt (met snmp traps). Nu zitten er in zo een pagina veel dezelfde regels. Ik wil nu op een scherm toveren of in een file de foutmeldingen, maar als er meer regels hetzelfde zijn die maar een keer laten zien met een tellertje hoeveel keer hij is geweest.
Doe eens "man uniq" :)

Verwijderd

Topicstarter
uniq? hmm, ff zoeken..

tot nu toe dacht in aan sed

hc

Verwijderd

crontab?

Verwijderd

hermanb: uniq? hmm, ff zoeken..
code:
1
uniq -c < in > out

Verwijderd

Op zaterdag 13 oktober 2001 20:38 schreef hermanb het volgende:
uniq? hmm, ff zoeken..

tot nu toe dacht in aan sed

hc
NAME
uniq - remove duplicate lines from a sorted file

SYNOPSIS
uniq [OPTION]... [INPUT [OUTPUT]]

DESCRIPTION
Discardall but one of successive identical lines from
INPUT (or standard input), writing to OUTPUT (or standard
output).

-c, --count
prefix lines by the number of occurrences

-d, --repeated
only print duplicate lines

-D, --all-repeated
print all duplicate lines

-f, --skip-fields=N
avoid comparing the first N fields

-i, --ignore-case
ignore differences in case when comparing

-s, --skip-chars=N
avoid comparing the first N characters

-u, --unique
only print unique lines

-w, --check-chars=N
compare no more than N characters in lines

-N same as -f N

+N same as -s N

--help display this help and exit

--version
output version information and exit

A field is a run of whitespace, then non-whitespace char
acters.Fields are skipped before chars.

REPORTING BUGS
Report bugs to <bug-textutils@gnu.org>.

SEE ALSO
The full documentation for uniq is maintained as a Texinfo
manual. If the infoand uniq programs are properly
installed at your site, the command

GNU textutils 2.0 August 19991

UNIQ(1) FSF UNIQ(1)

info uniq

should give you access to the complete manual.

COPYRIGHT
Copyright 1999 Free Software Foundation, Inc.
This is free software; see the source for copying condi
tions. There is NO warranty; not even for MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
Pagina: 1