troubleshooting Question

How to sort output of grep command

Avatar of Link
LinkFlag for United States of America asked on
Linux* BashSoftware
5 Comments1 Solution167 ViewsLast Modified:
I grep a directories logs (sys and dbg) for the strings "in service" or "out of service".

$ grep -e "in service" -e "out of service" *

The output returns both phrases found in the *.DBG  and then followed by that found in *.SYS  logs,  
From each log  the entire output (appears) sorted by the log timestamp from earliest to latest...
in other words I see earliest to latest from DBG log then earliest to latest from SYS log - all appended together as one output.

How can I then sort this output so all results found from (each log) are sorted together by time stamp alone,  Example output is below. (some output removed for brevity)

$ grep -V
grep (GNU grep) 3.0
Packaged by Cygwin (3.0-2)
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

1000010.DBG:142 10192017 164728.00001:1.09.00965.MAJOR   .ISDN : Service PRI-1-9-1-26 primary datalink state: in service
1000010.DBG:145 10192017 164804.00008:1.09.00974.MAJOR   .ISDN : Service PRI-1-9-1-1 primary datalink state: out of service
1000010.DBG:146 10192017 164912.00001:1.09.00978.MAJOR   .ISDN : Service PRI-1-9-1-26 primary datalink state: out of service
1000010.DBG:146 10192017 165043.00001:1.09.00983.MAJOR   .ISDN : Service PRI-1-9-1-26 primary datalink state: out of service
1000010.DBG:146 10192017 165213.00001:1.09.00987.MAJOR   .ISDN : Service PRI-1-9-1-26 primary datalink state: out of service
1000010.DBG:141 10192017 165244.00002:1.09.00988.MAJOR   .ISDN : Service PRI-1-9-1-1 primary datalink state: in service
1000010.DBG:146 10192017 165343.00001:1.09.00992.MAJOR   .ISDN : Service PRI-1-9-1-26 primary datalink state: out of service
1000010.DBG:146 10192017 165513.00001:1.09.00997.MAJOR   .ISDN : Service PRI-1-9-1-26 primary datalink state: out of service
1000010.DBG:146 10192017 165626.00001:1.09.01008.MAJOR   .ISDN : Service PRI-1-9-1-26 primary datalink state: out of service
1000010.DBG:146 10192017 165643.00001:1.09.01012.MAJOR   .ISDN : Service PRI-1-9-1-26 primary datalink state: out of service
1000010.DBG:142 10192017 165729.00002:1.09.01016.MAJOR   .ISDN : Service PRI-1-9-1-26 primary datalink state: in service
1000010.DBG:145 10192017 191204.00001:1.09.01173.MAJOR   .ISDN : Service PRI-1-9-1-1 primary datalink state: out of service
1000010.DBG:141 10192017 191204.00002:1.09.01174.MAJOR   .ISDN : Service PRI-1-9-1-1 primary datalink state: in service
1000010.DBG:145 10192017 201927.00088:1.09.01351.MAJOR   .ISDN : Service PRI-1-9-1-1 primary datalink state: out of service
1000010.DBG:141 10192017 201927.00089:1.09.01352.MAJOR   .ISDN : Service PRI-1-9-1-1 primary datalink state: in service
1000010.DBG:145 10192017 201927.00091:1.09.01353.MAJOR   .ISDN : Service PRI-1-9-1-2 primary datalink state: out of service
1000010.DBG:145 10192017 201927.00092:1.09.01354.MAJOR   .ISDN : Service PRI-1-9-1-3 primary datalink state: out of service
1000010.DBG:145 10192017 201927.00094:1.09.01355.MAJOR   .ISDN : Service PRI-1-9-1-4 primary datalink state: out of service
1000010.DBG:145 10192017 201927.00095:1.09.01356.MAJOR   .ISDN : Service PRI-1-9-1-8 primary datalink state: out of service
1000010.DBG:145 10192017 201928.00001:1.09.01357.MAJOR   .ISDN : Service PRI-1-9-1-9 primary datalink state: out of service
1000010.DBG:141 10192017 201928.00002:1.09.01358.MAJOR   .ISDN : Service PRI-1-9-1-9 primary datalink state: in service
1000010.DBG:146 10192017 201928.00004:1.09.01359.MAJOR   .ISDN : Service PRI-1-9-1-10 primary datalink state: out of service
1000010.DBG:141 10192017 201928.00005:1.09.01360.MAJOR   .ISDN : Service PRI-1-9-1-2 primary datalink state: in service
1000010.DBG:141 10192017 201928.00007:1.09.01361.MAJOR   .ISDN : Service PRI-1-9-1-3 primary datalink state: in service
1000010.DBG:141 10192017 201928.00009:1.09.01362.MAJOR   .ISDN : Service PRI-1-9-1-4 primary datalink state: in service
1000010.DBG:142 10192017 201929.00001:1.09.01363.MAJOR   .ISDN : Service PRI-1-9-1-10 primary datalink state: in service
1000010.DBG:141 10192017 201949.00001:1.09.01366.MAJOR   .ISDN : Service PRI-1-9-1-8 primary datalink state: in service
100001F.SYS:145 10192017 190757.00006:1.09.01188.MAJOR   .ISDN : ISDN Service PRI-1-9-1-1 primary D-channel out of service.
100001F.SYS:164 10192017 190757.00009:1.09.01190.MAJOR   .ISDN : ISDN Service PRI-1-9-1-1 Interface 0 B-channel out of service map 0xfffffe00.
100001F.SYS:141 10192017 191204.00003:1.09.01196.Minor   .ISDN : ISDN Service PRI-1-9-1-1 primary D-channel in service.
100001F.SYS:160 10192017 191206.00002:1.09.01197.Minor   .ISDN : ISDN Service PRI-1-9-1-1 Interface 0 B-channel in service map 0xfffffe00.
100001F.SYS:165 10192017 200613.00010:1.09.01231.MAJOR   .ISDN : ISDN Service PRI-1-9-1-26 Interface 0 B-channel out of service map 0xfffffe00.
100001F.SYS:146 10192017 200621.00004:1.09.01232.MAJOR   .ISDN : ISDN Service PRI-1-9-1-26 primary D-channel out of service.
100001F.SYS:145 10192017 201833.00009:1.09.01315.MAJOR   .ISDN : ISDN Service PRI-1-9-1-1 primary D-channel out of service.
100001F.SYS:145 10192017 201833.00014:1.09.01316.MAJOR   .ISDN : ISDN Service PRI-1-9-1-2 primary D-channel out of service.
100001F.SYS:145 10192017 201833.00019:1.09.01317.MAJOR   .ISDN : ISDN Service PRI-1-9-1-3 primary D-channel out of service.
100001F.SYS:145 10192017 201833.00024:1.09.01318.MAJOR   .ISDN : ISDN Service PRI-1-9-1-4 primary D-channel out of service.
100001F.SYS:145 10192017 201833.00068:1.09.01319.MAJOR   .ISDN : ISDN Service PRI-1-9-1-8 primary D-channel out of service.
100001F.SYS:145 10192017 201833.00070:1.09.01320.MAJOR   .ISDN : ISDN Service PRI-1-9-1-9 primary D-channel out of service.
100001F.SYS:146 10192017 201833.00071:1.09.01321.MAJOR   .ISDN : ISDN Service PRI-1-9-1-10 primary D-channel out of service.
100001F.SYS:164 10192017 201833.00224:1.09.01339.MAJOR   .ISDN : ISDN Service PRI-1-9-1-1 Interface 0 B-channel out of service map 0xfffffe00.
100001F.SYS:164 10192017 201833.00225:1.09.01340.MAJOR   .ISDN : ISDN Service PRI-1-9-1-2 Interface 0 B-channel out of service map 0xfffffe00.
100001F.SYS:164 10192017 201833.00226:1.09.01341.MAJOR   .ISDN : ISDN Service PRI-1-9-1-3 Interface 0 B-channel out of service map 0xfffffe00.
100001F.SYS:164 10192017 201833.00227:1.09.01342.MAJOR   .ISDN : ISDN Service PRI-1-9-1-4 Interface 0 B-channel out of service map 0xfffffe00.
100001F.SYS:164 10192017 201833.00228:1.09.01343.MAJOR   .ISDN : ISDN Service PRI-1-9-1-8 Interface 0 B-channel out of service map 0xfffffe00.
100001F.SYS:164 10192017 201833.00229:1.09.01344.MAJOR   .ISDN : ISDN Service PRI-1-9-1-9 Interface 0 B-channel out of service map 0xfffffe00.
100001F.SYS:165 10192017 201833.00230:1.09.01345.MAJOR   .ISDN : ISDN Service PRI-1-9-1-10 Interface 0 B-channel out of service map 0xfffffe00.
100001F.SYS:141 10192017 201927.00090:1.09.01615.Minor   .ISDN : ISDN Service PRI-1-9-1-1 primary D-channel in service.
100001F.SYS:141 10192017 201928.00003:1.09.01616.Minor   .ISDN : ISDN Service PRI-1-9-1-9 primary D-channel in service.
100001F.SYS:141 10192017 201928.00006:1.09.01617.Minor   .ISDN : ISDN Service PRI-1-9-1-2 primary D-channel in service.
100001F.SYS:141 10192017 201928.00008:1.09.01618.Minor   .ISDN : ISDN Service PRI-1-9-1-3 primary D-channel in service.
100001F.SYS:141 10192017 201928.00010:1.09.01619.Minor   .ISDN : ISDN Service PRI-1-9-1-4 primary D-channel in service.
100001F.SYS:142 10192017 201929.00002:1.09.01620.Minor   .ISDN : ISDN Service PRI-1-9-1-10 primary D-channel in service.
100001F.SYS:160 10192017 201929.00006:1.09.01622.Minor   .ISDN : ISDN Service PRI-1-9-1-1 Interface 0 B-channel in service map 0xfffffe00.
100001F.SYS:160 10192017 201930.00004:1.09.01623.Minor   .ISDN : ISDN Service PRI-1-9-1-9 Interface 0 B-channel in service map 0xfffffe00.
100001F.SYS:160 10192017 201930.00005:1.09.01624.Minor   .ISDN : ISDN Service PRI-1-9-1-2 Interface 0 B-channel in service map 0xfffffe00.
100001F.SYS:160 10192017 201930.00006:1.09.01625.Minor   .ISDN : ISDN Service PRI-1-9-1-3 Interface 0 B-channel in service map 0xfffffe00.
100001F.SYS:160 10192017 201931.00002:1.09.01626.Minor   .ISDN : ISDN Service PRI-1-9-1-4 Interface 0 B-channel in service map 0xfffffe00.
100001F.SYS:161 10192017 201931.00006:1.09.01627.Minor   .ISDN : ISDN Service PRI-1-9-1-10 Interface 0 B-channel in service map 0xfffffe00.
100001F.SYS:141 10192017 201949.00002:1.09.01646.Minor   .ISDN : ISDN Service PRI-1-9-1-8 primary D-channel in service.
ASKER CERTIFIED SOLUTION
Hugh Fraser
Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros