Hallo zusammen,
ich bin gerade dabei ein Aufgabe zu lösen aber komme irgendwie nicht klar. Ein Datei muss gescannt werden und anschließend bestimmte Zeilen müssen nach Ergebnisse ausgegeben werden.
Mein source Datei (Source.dat) besteht aus ein bestimmte Template
In meiner Datei sind mehrere Templates wie oben untereinander geschrieben. (mehr als 400)
Unten sehen Sie nur ein Teil davon mit 4 Templates
Mein Aufgabe lautet hier ein bestimmte Wort enthaltenen Templates zu finden und seine letzte Zeile auszugeben. Angenommen das Wort ist hier "Error". Unter dieser 4 Templates enthält nur 2. Templates das Wort "Error". Nun muss der letzte Zeile von 2. Templates ausgegeben werden. Also
Templates können unterschiedliche Grösse sein. (Also Anzahl von Zeilen) aber fangen immer mit From an und enden mit if Zeile. (Also ausgegebene Zeile).
Wie kann ich diese Aufgabe lösen?
Könnten Awk oder/und grep mir an dieser Stelle helfen?
ich bin gerade dabei ein Aufgabe zu lösen aber komme irgendwie nicht klar. Ein Datei muss gescannt werden und anschließend bestimmte Zeilen müssen nach Ergebnisse ausgegeben werden.
Mein source Datei (Source.dat) besteht aus ein bestimmte Template
Code:
From xxxxxxxxxxx Received: yyyyyyyyyyyyyyyyyy Date: Wed, 12 Sep 2012 01:32:57 +0200 (METDST) From: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz Message-Id: ooooooooooooooooooooooooooooooooooooooooo Subject: blabla Status: O ************************************************* Cron: The previous message is the standard output and standard error of one of your crontab commands: if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/GFXload tdpro_only ; fi
Unten sehen Sie nur ein Teil davon mit 4 Templates
From xxxxxxxxxxx
Received: yyyyyyyyyyyyyyyyyy
Date: Wed, 12 Sep 2012 01:32:57 +0200 (METDST)
From: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Message-Id: ooooooooooooooooooooooooooooooooooooooooo
Subject: blabla
Status: O
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/1 ; fi
From xxxxxxxxxxx
Received: yyyyyyyyyyyyyyyyyy
Date: Wed, 12 Sep 2012 01:32:57 +0200 (METDST)
From: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Message-Id: ooooooooooooooooooooooooooooooooooooooooo
Subject: blabla
Status: O
*************************************************
*************************************************
*************************************************
Error********************************************
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/2 ; fi
From xxxxxxxxxxx
Received: yyyyyyyyyyyyyyyyyy
Date: Wed, 12 Sep 2012 01:32:57 +0200 (METDST)
From: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Message-Id: ooooooooooooooooooooooooooooooooooooooooo
Subject: blabla
Status: O
*************************************************
*************************************************
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/1 ; fi
From xxxxxxxxxxx
Received: yyyyyyyyyyyyyyyyyy
Date: Wed, 12 Sep 2012 01:32:57 +0200 (METDST)
From: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Message-Id: ooooooooooooooooooooooooooooooooooooooooo
Subject: blabla
Status: O
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/1 ; fi
Received: yyyyyyyyyyyyyyyyyy
Date: Wed, 12 Sep 2012 01:32:57 +0200 (METDST)
From: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Message-Id: ooooooooooooooooooooooooooooooooooooooooo
Subject: blabla
Status: O
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/1 ; fi
From xxxxxxxxxxx
Received: yyyyyyyyyyyyyyyyyy
Date: Wed, 12 Sep 2012 01:32:57 +0200 (METDST)
From: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Message-Id: ooooooooooooooooooooooooooooooooooooooooo
Subject: blabla
Status: O
*************************************************
*************************************************
*************************************************
Error********************************************
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/2 ; fi
From xxxxxxxxxxx
Received: yyyyyyyyyyyyyyyyyy
Date: Wed, 12 Sep 2012 01:32:57 +0200 (METDST)
From: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Message-Id: ooooooooooooooooooooooooooooooooooooooooo
Subject: blabla
Status: O
*************************************************
*************************************************
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/1 ; fi
From xxxxxxxxxxx
Received: yyyyyyyyyyyyyyyyyy
Date: Wed, 12 Sep 2012 01:32:57 +0200 (METDST)
From: zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
Message-Id: ooooooooooooooooooooooooooooooooooooooooo
Subject: blabla
Status: O
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:
if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/1 ; fi
if [ -f $HOME/slab.ini ]; then $HOME/slab.ini $HOME/scripts/CronJobs/1 ; fi
Wie kann ich diese Aufgabe lösen?
Könnten Awk oder/und grep mir an dieser Stelle helfen?