Input file
My code so far
Desired output
My code terminates all the lines with [red]+[/red].
I need to get rid of that last [red]+[/red] and replace it with [red];[/red].
Can you also if you can provide with alternative approach to this problem.
Thaks.
Code:
1300483198 -4.60508
1300483199 -4.60825
1300483200 -4.60691
1300483201 -4.60581
1300483202 -4.60806
1300483203 -4.60747
1300483205 -4.60788
1300483206 -4.60704
1300483207 -4.60843
1300483208 -4.60675
1300483209 -4.60827
1300483210 -4.60721
1300483211 -4.60807
1300483212 -4.60778
1300483213 -4.60902
1300483215 -4.5526
1300483216 -4.68561
1300483217 -4.47417
1300483218 -4.50509
My code so far
Code:
#!/bin/awk
BEGIN{
print "function MyData(){ \n return \42\42+\n\42 Date,A, \\n \42+\
" }
{printf("%s", strftime("\42%Y/%m/%d ",$1));
printf("%s", strftime("%H:%M:%S,",$1));
print $2 "\\n\42+" }
END{ print "}" }
Desired output
Code:
function MytData(){
return ""+
" Date,A, \n "+
"2011/03/18 16:19:58,-4.60508\n"+
"2011/03/18 16:19:59,-4.60825\n"+
"2011/03/18 16:20:00,-4.60691\n"+
"2011/03/18 16:20:01,-4.60581\n"+
"2011/03/18 16:20:02,-4.60806\n"+
"2011/03/18 16:20:03,-4.60747\n"+
"2011/03/18 16:20:05,-4.60788\n"+
"2011/03/18 16:20:06,-4.60704\n"+
"2011/03/18 16:20:07,-4.60843\n"+
"2011/03/18 16:20:08,-4.60675\n"+
"2011/03/18 16:20:09,-4.60827\n"+
"2011/03/18 16:20:10,-4.60721\n"+
"2011/03/18 16:20:11,-4.60807\n"+
"2011/03/18 16:20:12,-4.60778\n"+
"2011/03/18 16:20:13,-4.60902\n"+
"2011/03/18 16:20:15,-4.5526\n"+
"2011/03/18 16:20:16,-4.68561\n"+
"2011/03/18 16:20:17,-4.47417\n"+
"2011/03/18 16:20:18,-4.50509\n";
}
I need to get rid of that last [red]+[/red] and replace it with [red];[/red].
Can you also if you can provide with alternative approach to this problem.
Thaks.