Reputation: 8047
E.g, I've got a build.log file, each line is like this:
[2017-02-13 16:37:41.123456] [warning] [1743] [mysource/impl.cpp:25] Syntax warning ...
I need to convert its format to be like this:
[warning] [1743] [mysource/impl.cpp:25] Syntax warning ...[2017-02-13 16:37:41.123456]
So my question is, how to cut the leading timestamp within the first [] and paste to line end?
How to do it wish bash/sed/awk(anyway)? Thanks.
Upvotes: 0
Views: 116
Reputation: 37023
Try something like:
echo "[2017-02-13 16:37:41.123456] [warning] [1743] [mysource/impl.cpp:25] Syntax warning " | awk -F" " '{for(i=3;i<=NF;++i)printf ("%s ", $i); printf("%s %s\n", $1, $2)}'
Upvotes: 2