Reputation: 37367
If I have output like this (from customized git log)
d1fd022 2011-09-21 17:02:26 -0400 Replace double quotes with single quotes.
7227fe4 2011-09-21 13:57:36 -0400 Add automatic CommandTFlush to mkdir/rm/touch/cd
How could you pipe it through sed
, awk
or similar to achieve this output?
d1fd022 2011-09-21 17:02 Replace double quotes with single quotes.
7227fe4 2011-09-21 13:57 Add automatic CommandTFlush to mkdir/rm/touch/cd
Here the only difference is that seconds and timezone are cut out from the date. Unfortunately, git doesn't seem to support custom date formats and I'm not good with the likes of sed
, so need some help.
Upvotes: 1
Views: 845
Reputation: 15954
I suggest using cut
(POSIX):
[guest@pawel] ~ $ cut -c 1-24,34- foo.txt
d1fd022 2011-09-21 17:02 Replace double quotes with single quotes.
7227fe4 2011-09-21 13:57 Add automatic CommandTFlush to mkdir/rm/touch/cd
Upvotes: 2
Reputation: 28000
sed 's/:[^:]* -[^ ]*//' infile
Fixed (it's not a space, it's a tab).
Upvotes: 0
Reputation: 195059
awk version:
awk -F':[0-9][0-9] | ' '{$4=""}1' inputFile
test:
kent$ echo "d1fd022 2011-09-21 17:02:26 -0400 Replace double quotes with single quotes.
7227fe4 2011-09-21 13:57:36 -0400 Add automatic CommandTFlush to mkdir/rm/touch/cd"|awk -F':[0-9][0-9] | ' '{$4=""}1'
d1fd022 2011-09-21 17:02 Replace double quotes with single quotes.
7227fe4 2011-09-21 13:57 Add automatic CommandTFlush to mkdir/rm/touch/cd
Upvotes: 1