hi all
i want help in sortng date in paragraphs within file ,
i want to ask as if there any option to sort a certain pattern of file not the rest of file.i.e the data of file become sorted with respect to date
i have a log file as follows
!!! *A0628/080 /08-01-10/13 H 52/N=5527/TYP=INC/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 7/AGEO=ADABOSAN-B01
/TEXAL=FIRE
!!! *A0628/087 /08-01-16/01 H 28/N=7648/TYP=CLI/CAT=IM/EVENT=MAL
/NCEN=MULCT /AFUR =URAD- 10/AGEO=RANGPUR -B01
i want to extract the date , time , NCEN , EVENT , TAXAL & AGEO
i used the code following
this code does seperate the paragraphs follwing ! , !! , !!! (i.e. minor , major & critical alarms of the log file respectively ,in their respective log files i.e. minor.log ,major.log & critical.log )
and 'awk' gives me output as following
! *A0628/07-12-17/15 H 58/
NCEN=MULCT
AGEO=S1-TR01-B03-A085-R000
EVENT=MAL
TEXAL=AIS/COMPL.INF:/ /AF=URMA1
but i want the output to be sorted by date
(date pattern=/07-12-17/)
i tried to use the sort -k but i coldnt understand the right pattern to use it
or I have to sort this date pattern by loops ?
cant understand???
i tried to sort the date pattern by reg exp and to some extent i suceeded by i ca only compare two dated i couldnt get the logic to make the loop to check each date in file and then puxh the latest date entry on top each time
i used the code plz do it if u can or tell me the right way to go ahead
Is each record separated by a newline?? I can't tell, because sometimes the records have two newlines.
actually the line pattern is not regular but i extracted the output data
from file i.e. date , time ,NCEN , TAXAL , EVENT ,& AGEO
now i have the regular 1 line space in output
! *A0628/07-12-17/15 H 58/
NCEN=MULCT
AGEO=S1-TR01-B03-A085-R000
EVENT=MAL
TEXAL=AIS/COMPL.INF:/ /AF=URMA1
i used the following code to extract
now i need to sort it by date
but couldnt find the way
Dude, that's way overkill. I guess for python programmers, every problem is a nail?
nabmufti,
The normal sort routine will work. It looks like the date field is the third one within slashes, correct? If so, we can just do this:
sort -t / -k 3,4
Pipe the output of your script into this sort, and that should be it! Now, this works because the date is in proper lexical order (YY-MM-DD) and doesn't require individual sorting of the number space. If you had DD-MM-YY, it would be a tad bit trickier.
If you have multiple events on the same day, an you want to sort on another field, you can add a -k parameter:
as friends can only Sort this file with awk from low to high from position 3 to 9 bone this:
0003344
A70003344prueba1
A70003347prueba1
A70003345prueba1
A70003349prueba1
A70003343prueba1
A70003342prueba1 (4 Replies)
Hi Experts,
I have a filelist collected from another server , now want to sort the output using date/time stamp filed.
- Filed 6, 7,8 are showing the date/time/stamp.
Here is the input:
#----------------------------------------------------------------------
-rw------- 1 root ... (3 Replies)
Input file:
100%ABC2 3.44E-12 USA
A2M%H02579 0E0 UK
100%ABC2 5.34E-8 UK
100%ABC2 3.25E-12 USA
A2M%H02579 5E-45 UK
Output file:
100%ABC2 3.44E-12 USA
100%ABC2 3.25E-12 USA
100%ABC2 5.34E-8 UK
A2M%H02579 0E0 UK
A2M%H02579 5E-45 UK
Code try:
sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Need to sort a portion of a file in a Alphabetical Order.
Example : The user adam is not sorted and the user should get sorted. I don't want the complete file to get sorted.
Currently All_users.txt contains the following lines.
##############
# ARS USERS
##############
mike, Mike... (6 Replies)
Hello all -
I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Hi to all.
I'm trying to sort this with the Unix command sort.
user1:12345678:3.5:2.5:8:1:2:3
user2:12345679:4.5:3.5:8:1:3:2
user3:12345687:5.5:2.5:6:1:3:2
user4:12345670:5.5:2.5:5:3:2:1
user5:12345671:2.5:5.5:7:2:3:1
I need to get this:
user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
I have a file below which has a list of users and roles with each row having unique combination of users and roles.
USER1 ROLE1
USER1 ROLE2
USER2
USER3 ROLE1
USER3 ROLE2
USER3 ROLE3
USER4 ROLE2
....
....
I am trying to create a script which sorts the above file to have all the... (4 Replies)
Hi,
I have a file with the list of RPMs in the following format
unix-abc-bin-1.27.1-006901
unix-abc-cfg-1.27.1-006901
unix-xyz-bin-1.27.1-006901
unix-abc-bin-1.27.2-006902
unix-xyz-bin-1.27.2-006902
unix-xyz-img-1.27.2-006902
I need the output as shown below
unix-abc-bin-1.27.2-006902... (4 Replies)