Pregunta

I have a file:

fakdfal
14867
kgjafdfrf
8423685

I want to get the result:

fakd.fal
14.867
kgjafd.frf
8423.685
¿Fue útil?

Solución

Using awk:

awk '{sub(/...$/, ".&"); print}'

Using sed:

sed 's/...$/.&/'

Otros consejos

Using sed it is simpler:

sed -i.bak 's/...$/.&/' file

OR awk solution:

awk 'length($0)> 3 {l=length($0); $0=substr($0, 1, l-3) "." substr($0, l-2)} 1' file
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top