Reputation: 6365
I have log file, and here is output:
2014109 13:42:17;10.8.0.6;/home/spy/www/index.html;13
yearmonthday
I need to change date format -> 2014109
to 20141009
.
I change Oct
format to 10
, using sed:
sed -i 's/Oct/10/g;
How can i use sed for day format?
Upvotes: 1
Views: 128
Reputation: 780861
If the first field is only 7 digits, insert a zero before the last digit:
sed -r -i 's/^([0-9]{6})([0-9])\b/\10\2/'
Upvotes: 3