I am using the following command on Terminal in MacBook.
printf "The number is %'d\n" 123456
I expect the output:
The number is 123,456.
But I am getting:
The number is 123456.
Please point out my mistake.
I am using the following command on Terminal in MacBook.
printf "The number is %'d\n" 123456
I expect the output:
The number is 123,456.
But I am getting:
The number is 123456.
Please point out my mistake.
Please point out my mistake.
I guess you mean this:
printf "%'.3d\n" 123456
123,456
Bear in mind that the separator depends on your locale
.
LC_NUMERIC="en_US.UTF-8"
printf "%'.3d\n" 123456
123,456
LC_NUMERIC="sv_SE.UTF-8"
printf "%'.3d\n" 123456
123 456
There is a good description available here.