How to sort grep result based on timestamp?

Hi,

Trying to sort grep result based on timestamp of the filename.
I have the following result and want to sort them on timestamp

grep -i  'ERROR' *log*2013*[0-9]
s_m_xxx_xxx_xxx_xxx_xxxx.log.20130906092431:TRANSF_1_1_1> DBG_21216 Finished transformations for Source Qualifier [SQ_xxxxxxxxxx#]. Total errors [0]
s_m_xxx_xxx_xxx_xxx_xxxx.log.20130906092431:MAPPING> TM_6018 The session completed with [0] row transformation errors.
s_m_yyy_yyy_yyy_yyy_yyy_yyy_yyy.log.20130909131721:DIRECTOR> TM_6708 Using configuration property [ConnectionErrorCodesFile,/informatica/dev/pc901/server/bin/connect_errors.act]
s_m_yyy_yyy_yyy_yyy_yyy_yyy_yyy.log.20130909131721:MAPPING> TM_6307 DTM error log disabled.
s_m_zzz_zzz_zzz_zzzzzz.log.20130827072827:DIRECTOR> TM_6708 Using configuration property [ConnectionErrorCodesFile,/informatica/dev/pc901/server/bin/connect_errors.act]
s_m_zzz_zzz_zzz_zzzzzz.log.20130827072827:MAPPING> TM_6307 DTM error log disabled.
s_m_zzz_zzz_zzz_zzzzzz.log.20130827072827:MAPPING> MQ_29004 Filter parse error: Line 1, column 4: Left operand must be boolean

Thanks in Advance for your time and help

Well they're in YYYYMMDD order already which is convenient.

We tell it to split fields on . then sort on characters 1 through 15 of the third field.

sort -t. -k 3.1,3.15 < infile > outfile
1 Like

Hello,
sort list file before or after grep ?

Regard.

It'll work either way, but it'd be much less work to sort after -- less data to sort.

@disedorgue

Want to sort the result of grep

@Corona688 - Thanks