help with sed
Nils Kassube
kassube at gmx.net
Wed Jun 27 06:03:13 UTC 2012
Joep L. Blom wrote:
> I have a little conversion problem and I'm not well versed in sed. I
> know there are several sed-wizards on this list so therefore I hope
> somebody can make the solution.
> I have a an ASCII table in .csv format.
> Now the first 5 columns are day,month,year,hour.minute. all values
> separated by comma's.
> I would like to convert that to "day-month-year hour:minute:second",
> meaning inserting an extra ":0" after the minute column.
> To give an example: the second row is:
> 1,8,2011,10,0,....,...,..., etc.
> I want this to convert to one date-time column with format:
> 1-8-2011 10:0:0 or eventually one date and one time column. The rest
> must stay as is (i.e. comma separated).
I'm not a sed-wizard either, but this is what I would use:
~/ > echo '1,8,2011,10,0,a,b,c,...'|sed -e s/,/-/ -e s/,/-/ -e s/,/\ / -e s/,/:/ -e s/,/:0,/
1-8-2011 10:0:0,a,b,c,...
Nils
More information about the ubuntu-users
mailing list