Extract Content from a file

I have an input file with contents like:

./prbru6/12030613.LOG:24514|APPL|prbru6.8269.RTUDaemon.1|?|13:49:56|12/03/06|GMT+3|?|RTUServer Error:Count of Internal    Error Qty (-1) < 0, for Audit group id - 1L5XVJ6DQE36AXL, after record number,1, File: EventAuditor.cc, Line: 394|?    ./prbru6/12030613.LOG:3031|APPL|prbru6.8269.RTUDaemon.1|?|13:49:56|12/03/06|GMT+3|?|Application error.AUDIT UPDATE ERROR,    File: EventAggregator.cc, Line: 335|?    ./prbru6/12030613.LOG:24514|APPL|prbru6.8269.RTUDaemon.1|?|13:49:57|12/03/06|GMT+3|?|RTUServer Error:Count of Internal    Error Qty (-1) < 0, for Audit group id - 1LM0DJKDN8QRB2T, after record number,1, File: EventAuditor.cc, Line: 394|?    ./prbru6/12030613.LOG:3031|APPL|prbru6.8269.RTUDaemon.1|?|13:49:57|12/03/06|GMT+3|?|Application error.AUDIT UPDATE ERROR,    File: EventAggregator.cc, Line: 335|?    ./prbru6/12030613.LOG:24514|APPL|prbru6.8269.RTUDaemon.1|?|13:49:59|12/03/06|GMT+3|?|RTUServer Error:Count of Internal    Error Qty (-1) < 0, for Audit group id - 1LE65JSD4TJ3TE0, after record number,2, File: EventAuditor.cc, Line: 394|?    ./prbru6/12030613.LOG:3031|APPL|prbru6.8269.RTUDaemon.1|?|13:49:59|12/03/06|GMT+3|?|Application error.AUDIT UPDATE ERROR,    File: EventAggregator.cc, Line: 335|?

I need to extract the fields 1LM0DJKDN8QRB2T,1LE65JSD4TJ3TE0 and so on from the file.can anyone help me in this :frowning:

---------- Post updated at 12:33 AM ---------- Previous update was at 12:27 AM ----------

content of filw will be lyk the following:

24514|APPL|prbru7.16318.RTUDaemon.1|?|23:37:55|12/03/18|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, f
or Audit group id - 1LMXTJJD0W28TX2, after record number,0, File: EventAuditor.cc, Line: 394|?
24514|APPL|prbru7.16336.RTUDaemon.1|?|23:37:57|12/03/18|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, f
or Audit group id - 1LS1XJGDEVWAC5T, after record number,1, File: EventAuditor.cc, Line: 394|?
24514|APPL|prbru7.16315.RTUDaemon.1|?|23:38:06|12/03/18|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, f
or Audit group id - 1LK81JVDE2HRNDG, after record number,0, File: EventAuditor.cc, Line: 394|?
$ awk -F"[,\-]" '{print $4}' test.txt
 1LMXTJJD0W28TX2
 1LS1XJGDEVWAC5T
 1LK81JVDE2HRNDG

it didnt work:

more LOG.dat

24514|APPL|prbru7.16318.RTUDaemon.1|?|23:37:55|12/03/18|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, f
or Audit group id - 1LMXTJJD0W28TX2, after record number,0, File: EventAuditor.cc, Line: 394|?
24514|APPL|prbru7.16336.RTUDaemon.1|?|23:37:57|12/03/18|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, f
or Audit group id - 1LS1XJGDEVWAC5T, after record number,1, File: EventAuditor.cc, Line: 394|?
24514|APPL|prbru7.16315.RTUDaemon.1|?|23:38:06|12/03/18|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, f
or Audit group id - 1LK81JVDE2HRNDG, after record number,0, File: EventAuditor.cc, Line: 394|?

awk -F"[,\-]" '{print $4}' LOG.dat

It didnt print anything except some null lines :frowning:

Hi,

Try this one,

sed 's/.*-\(.*\),.*,.*,.*,.*/\1/g' file
 
if the value is in same postion and length then here is the simple awk.
awk '{print substr($0,140,15);}' file
 

Cheers,
Ranga:)

Tried but not worked:(

burrow% sed 's/.*-\(.*\),.*,.*,.*,.*/\1/g' LOG.dat
24514|APPL|prbru7.16318.RTUDaemon.1|?|23:37:55|12/03/18|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, f
 1LMXTJJD0W28TX2
24514|APPL|prbru7.16336.RTUDaemon.1|?|23:37:57|12/03/18|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, f
 1LS1XJGDEVWAC5T
24514|APPL|prbru7.16315.RTUDaemon.1|?|23:38:06|12/03/18|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, f
 1LK81JVDE2HRNDG
burrow% awk '{print substr($0,140,15);}' LOG.dat
 
 
 

Your inputs file got splitted into two lines, kindly look into your input file. All the above commands are working fine.
else this is the exact input file ? you are having 6 lines of input ?