Reputation: 9
I am fairly new to awk, and I am having a file with four columns, separated by a space and I would like to change the date format of the 2nd and third column. I have shared a sample of the record below
349287741 20140123 20140329 7
I would like to change the date from %Y%m%d to %Y-%m-%d without affecting the record positions.
Upvotes: 0
Views: 48
Reputation: 14949
You can try this awk
,
awk '{ "date -d "$2" +%Y-%m-%d"|getline $2; "date -d "$3" +%Y-%m-%d"|getline $3;}1' yourfile
Upvotes: 1