![]() |
how to sort output at latest entries without disturbing the previous entries record
hi all
i need to sort the output entry by entry i am dealing with a log file of alkatel switch keeping three types of alarms i.e. minor (!) , major (!!) , and critical (!!!). ineed to sort in order !!! then !! and ! in last to make it more clear i give u an example that if i get 5 alarms in night and i open log file on next morning then !!!critcal alarm 'd be at first position then !! major alarm and ! minor alarm in the last, my file sample is given below !!! *A0628/303 /07-12-17/15 H 46/N=7506/TYP=COM/CAT=IM/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 7/AGEO=ADABOSAN-B01 /TEXAL=SINGLE JUNCT/UT OOS/COMPL.INF: /CN=2 !!! *A0628/303 /07-12-17/15 H 50/N=7507/TYP=COM/CAT=IM/EVENT=MAL /NCEN=MULCT /AFUR =URAD- 11/AGEO=QADIRPUR-B01 /TEXAL=SINGLE JUNCT/LINK DOWN /COMPL.INF: /CN=2 !! *A0628/538 /07-12-17/12 H 52/N=7576/TYP=ICT/CAT=ID/EVENT=MAL /NCEN=MULCT /AM =SMTA1/AGEO=S1-TR01-B03-A085-R000 /TEXAL=LCL MFM SYN/COMPL.INF: /AF=URMA1 / ICTRQ AGCA=S1-TR01-B03-A085-R133 /AMET=01-26-03 /AFLR=217-06/CRC=NACT ! *A0628/540 /07-12-17/15 H 58/N=7598/TYP=ICT/CAT=SI/EVENT=MAL /NCEN=MULCT /AM =SMTA1/AGEO=S1-TR01-B03-A085-R000 /TEXAL=AIS/COMPL.INF: /AF=URMA1 / ICTRQ AGCA=S1-TR01-B03-A112-R065 /AMET=01-07-02 /AFLR=222-09/CRC=NACT I am using the following code to extract output from log file , Code:
#!/bin/bash! *A0628 07-12-17/15 H 58/ NCEN=MULCT AGEO=S1-TR01-B03-A085-R000 EVENT=MAL TEXAL=AIS/COMPL.INF: but the problem is this , it extracts output in three seperate log files i.e. minor.log , major.log ,critical.log i want to see all out put from switch to a single log file in above sorted manner (as file sample above) wait for reply soon |
Do you want to just combine the files?
If so then this will do it. Code:
cat critical.log major.log minor.log > output.log |
i dont want it to combine
i realy dont want to combine these files
i want to sort the new alarms i think it can be done using gawk instead awk, and i am trying to do so but still i am looking for the right command to do i again try to make it clear e.g. if i have 5 alarms unchecked in the file as latest enteries in log file then i want them in order as follows , !!! critical alarm at first !! major alarm at second & ! minor alarm in last when log fie is updated i am usung the code i posted in thread above hoping it will be more clear now |
Quote:
Quote:
You either use this directly or pipe the concatenated files as input to your awk command: Code:
sed '/^!/i\ |
Quote:
Anyways, this should get you started. Code:
$ cat biglogCode:
$ awk 'BEGIN{RS="";ORS="\n\n"} /^!!! /{critical[$0]} END{for (line in critical){print line}}' biglog Code:
sed '/^!/i' biglogBest of luck. Edit: Sigh... The whole sed+awk combination bugged me, so I couldn't go to sleep without changing it to be all in awk... Code:
BEGIN{RS="!+ ";ORS="\n\n"}Code:
awk -f foo.awk biglog |
| All times are GMT -5. The time now is 06:56 PM. |