Sample Header Ad - 728x90

grep first n and last n characters from a line in a file

10 votes
8 answers
40777 views
I have a log file which looks like: Mar 23 08:20:23 New file got created in sec: 235 Mar 23 08:21:45 New file got created in sec: 127 Mar 23 08:22:34 New file got created in sec: 875 Mar 23 08:25:46 New file got created in sec: 322 Mar 23 08:26:12 New file got created in sec: 639 I need the output to look like: Mar 23 08:20:23 : 235 Mar 23 08:21:45 : 127 Mar 23 08:22:34 : 875 Mar 23 08:25:46 : 322 Mar 23 08:26:12 : 639 What I am able to do is just grep either first part or the last part of the line. I am not able to put the two together. How can I get the desired output from my input?
Asked by IAmNoob (209 rep)
Mar 24, 2017, 03:42 AM
Last activity: Dec 12, 2024, 11:36 PM