temperature - Sed pattern to exclude values -


i have file temperature values:

$ cat temperature.txt [1450746005000,18.00],[1450746365000,18.00],[1450746725000,17.94],[1450747085000,17.94],[1450747445000,17.94],[1450747805000,17.94],[1450748165000,17.94],[1450748525000,17.88],[1450748885000,17.88],[1450749245000,17.88],[1450749606000,17.88], 

sometimes station saves wrong values like: (a second value)

[1453634645000,19.06],[1453635364000,[1453658405000,19.13], 

i remove wrong value , overwrite file. in case [1453635364000,

i found out how search "good" values. don't have idea how remove wrong ones.

sed 's/\[[^]]*,?\],*//g' temperature.txt > temperature.txt.proper rm temperature.txt && mv temperature.txt.proper temperature.txt 

try this:

sed 's/[[0-9]\+,\[/[/g;s/[[0-9]\+,$//g' file 

to edit file "in place" add sed's option -i.


Comments