Thread Zeilen löschen aus Array, wenn bestimmte Strings enthalten (17 answers)
Opened by cohama at 2012-05-14 13:40

cohama
 2012-05-14 13:40
#158340 #158340
User since
2011-08-16
102 articles
BenutzerIn

user image
Hallo zusammen,

ich suche seit einiger Zeit nach einer Lösung bzw. Ansatz um eine Zeile aus einem Array zu löschen, wenn in dieser Zeile fest gelegte Strings auftreten.
Insgesamt geht es darum eine SysLog-Datei zu verarbeiten und hierei auf Zeilen zu verzichten, die das Trouble-Shooting des Systems nicht voran bringen.

In den folgenden Zeile soll nach WLAN gesucht werden und diese Zeile aus dem Array gelöscht werden.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
May 08 01:16:17         user.crit   192.178.168.15 May  7 23:16:17 rfp: 0074388084 ***** MAIN: connect OMM: Connection timed out
May 08 01:17:52 user.crit 192.178.168.15 May 7 23:17:52 rfp: 0074407091 ***** MAIN: connect OMM: Connection refused
May 08 09:20:00 daemon.info 192.178.168.15 May 8 07:20:00 snmpd[2306]: NET-SNMP version 5.1.2
May 08 11:35:10 daemon.info 192.178.168.15 May 8 09:35:11 init: starting pid 2318, tty '/dev/null': '/sbin/shutdown'
May 08 11:35:10 user.info 192.178.168.15 May 8 09:35:11 shutdown: running /sbin/shutdown
May 08 11:35:13 daemon.info 192.178.168.15 May 8 09:35:14 init: The system is going down NOW!
May 08 11:35:13 daemon.info 192.178.168.15 May 8 09:35:14 init: Sending SIGTERM to all processes
May 08 11:38:44 user.info 192.178.168.15 Nov 30 00:00:08 kernel: br0: port 1(eth0) entering forwarding state
May 08 11:38:44 user.info 192.178.168.15 Nov 30 00:00:08 kernel: br0: topology change detected, propagating
May 08 11:38:45 authpriv.info 192.178.168.15 Nov 30 00:00:09 dropbear[150]: Not backgrounding
May 08 11:38:45 daemon.info 192.178.168.15 Nov 30 00:00:09 init: starting pid 162, tty '/dev/null': '/opt/rfpm/rfpm'
May 08 11:38:45 user.notice 192.178.168.15 Nov 30 00:00:09 rfp: 0000002133 ! MAIN: Starting iprfp ...
May 08 11:38:45 user.notice 192.178.168.15 Nov 30 00:00:09 rfpm: 0000002139 ! MAIN: Starting rfpm ...
May 08 11:38:46 user.notice 192.178.168.15 Nov 30 00:00:10 rfp: 0000002349 ! MAIN: starting RFP application
May 08 11:38:48 user.notice 192.178.168.15 Nov 30 00:00:12 /etc/sysconfig/B20network: added default gateway
May 08 11:38:50 user.info 192.178.168.15 Nov 30 00:00:14 M20sntpc: starting sntpc
May 08 11:38:50 user.notice 192.178.168.15 Nov 30 00:00:14 sntpc: 0000003167 ** MAIN: sntp client started
May 08 11:38:50 user.notice 192.178.168.15 May 8 09:38:51 sntpc: 0000003181 ** MAIN: local clock set to Tue May 8 09:38:51 UTC 2012, offset was 392549916.323315
May 08 11:38:53 user.info 192.178.168.15 May 8 09:38:53 wlan: Initialized /var/run/wlan//storage_file (no data)
May 08 11:38:53 daemon.info 192.178.168.15 May 8 09:38:53 init: reloading /etc/inittab
May 08 11:39:06 daemon.info 192.178.168.15 May 8 09:39:06 snmpd[357]: NET-SNMP version 5.1.2
May 08 11:39:35 user.warn 192.178.168.15 May 8 09:39:35 kernel: WLAN driver starting
May 08 11:39:41 user.info 192.178.168.15 May 8 09:39:41 kernel: WLAN driver UP & RUNNING
May 08 11:39:41 user.info 192.178.168.15 May 8 09:39:41 kernel: device wlan0 entered promiscuous mode
May 08 11:39:41 user.info 192.178.168.15 May 8 09:39:41 kernel: br0: port 2(wlan0) entering learning state
May 08 11:39:42 user.info 192.178.168.15 May 8 09:39:42 kernel: br0: port 2(wlan0) entering forwarding state
May 08 11:39:42 user.info 192.178.168.15 May 8 09:39:42 kernel: br0: topology change detected, propagating
May 08 17:21:31 daemon.info 192.178.168.15 May 8 15:21:31 snmpd[357]: Received TERM or STOP signal... shutting down...
May 08 17:21:56 user.crit 192.178.168.15 May 8 15:21:56 rfp: 0004120191 ***** MAIN: connect OMM: Connection refused
May 08 17:21:56 user.crit 192.178.168.15 May 8 15:21:56 rfp: 0004120209 ***** MAIN: ; version = ''; type = RFP 42; capabilities = 3fc)
May 08 17:21:57 daemon.info 192.178.168.15 May 8 15:21:57 snmpd[19095]: NET-SNMP version 5.1.2
May 08 17:22:23 user.warn 192.178.168.15 May 8 15:22:23 kernel: WLAN driver starting
May 08 17:22:29 user.info 192.178.168.15 May 8 15:22:29 kernel: WLAN driver UP & RUNNING
May 08 17:22:29 user.info 192.178.168.15 May 8 15:22:29 kernel: device wlan0 entered promiscuous mode
May 08 17:22:29 user.info 192.178.168.15 May 8 15:22:29 kernel: br0: port 2(wlan0) entering learning state
May 08 17:22:30 user.info 192.178.168.15 May 8 15:22:30 kernel: br0: port 2(wlan0) entering forwarding state
May 08 17:22:30 user.info 192.178.168.15 May 8 15:22:30 kernel: br0: topology change detected, propagating


Vielen Dank für die Hinweise im Voraus.

View full thread Zeilen löschen aus Array, wenn bestimmte Strings enthalten