Dear Experts
i have a text file some thing like
1,4,4
1,3,6
1,7,8
i need to divide the last colunm by two and need the output like this
1,4,4,2
1,3,6,3
1,7,8,4
Please an any body make the script and try to ave in other file.
Regards,
Dear Experts
i have a text file some thing like
1,4,4
1,3,6
1,7,8
i need to divide the last colunm by two and need the output like this
1,4,4,2
1,3,6,3
1,7,8,4
Please an any body make the script and try to ave in other file.
Regards,
Hi,
Try this,
awk -F, '{print $0 "," $NF/2}' inp.txt > out.txt
Regards,
Chella
Hi
Thank you so much it really works could you please tell me one thing more it giving te out put in decimal values.
i just want to round up the calues annd i want the round up values for example $NF/2 will give you 23.777 it should give me 24.
how can i do that
awk -F, '{printf("%s,%.2f\n",$0,$NF/2) }' inp.txt
A small correction for the OP
awk -F, '{printf("%s,%.f\n",$0,$NF/2)}' inp.txt
thanks its really working fine
could you please tell me that what is %s and %.f
awk -F, '{printf("%s,%.f\n",$0,$NF/50)}' input.txt