Skip to main content
edited tags
Link
added 518 characters in body
Source Link
Vesnog
  • 689
  • 4
  • 12
  • 29

In Ubuntu 14.04.1 LTS 64-bit bash I am declearing floating point variables by multiplying floating point bash variables in bc with scale set to 3; however, I cannot get the number of digits after the decimal point to be zero and get rid of the zero to the left of the decimal point. How can I transform, say 0.005000000 into .005? This is necessary due to my file naming convention. Thanks for your recommendations.

UPDATE: Can I use it for already defined shell variables and redefining them? The following code gives me an error.

~/Desktop/MEEP$ printf "%.3f\n" $w bash: printf: 0.005000: invalid number 0,000 

The output of locale

@vesnog:~$ locale LANG=en_US.UTF-8 LANGUAGE=en_US LC_CTYPE="en_US.UTF-8" LC_NUMERIC=tr_TR.UTF-8 LC_TIME=tr_TR.UTF-8 LC_COLLATE="en_US.UTF-8" LC_MONETARY=tr_TR.UTF-8 LC_MESSAGES="en_US.UTF-8" LC_PAPER=tr_TR.UTF-8 LC_NAME=tr_TR.UTF-8 LC_ADDRESS=tr_TR.UTF-8 LC_TELEPHONE=tr_TR.UTF-8 LC_MEASUREMENT=tr_TR.UTF-8 LC_IDENTIFICATION=tr_TR.UTF-8 LC_ALL= 

The output of echo $w

@vesnog:~$ echo $w 0.005000 

In Ubuntu 14.04.1 LTS 64-bit bash I am declearing floating point variables by multiplying floating point bash variables in bc with scale set to 3; however, I cannot get the number of digits after the decimal point to be zero and get rid of the zero to the left of the decimal point. How can I transform, say 0.005000000 into .005? This is necessary due to my file naming convention. Thanks for your recommendations.

UPDATE: Can I use it for already defined shell variables and redefining them? The following code gives me an error.

~/Desktop/MEEP$ printf "%.3f\n" $w bash: printf: 0.005000: invalid number 0,000 

In Ubuntu 14.04.1 LTS 64-bit bash I am declearing floating point variables by multiplying floating point bash variables in bc with scale set to 3; however, I cannot get the number of digits after the decimal point to be zero and get rid of the zero to the left of the decimal point. How can I transform, say 0.005000000 into .005? This is necessary due to my file naming convention. Thanks for your recommendations.

UPDATE: Can I use it for already defined shell variables and redefining them? The following code gives me an error.

~/Desktop/MEEP$ printf "%.3f\n" $w bash: printf: 0.005000: invalid number 0,000 

The output of locale

@vesnog:~$ locale LANG=en_US.UTF-8 LANGUAGE=en_US LC_CTYPE="en_US.UTF-8" LC_NUMERIC=tr_TR.UTF-8 LC_TIME=tr_TR.UTF-8 LC_COLLATE="en_US.UTF-8" LC_MONETARY=tr_TR.UTF-8 LC_MESSAGES="en_US.UTF-8" LC_PAPER=tr_TR.UTF-8 LC_NAME=tr_TR.UTF-8 LC_ADDRESS=tr_TR.UTF-8 LC_TELEPHONE=tr_TR.UTF-8 LC_MEASUREMENT=tr_TR.UTF-8 LC_IDENTIFICATION=tr_TR.UTF-8 LC_ALL= 

The output of echo $w

@vesnog:~$ echo $w 0.005000 
Additional information
Source Link
Vesnog
  • 689
  • 4
  • 12
  • 29

In Ubuntu 14.04.1 LTS 64-bit bash I am declearing floating point variables by multiplying floating point bash variables in bc with scale set to 3; however, I cannot get the number of digits after the decimal point to be zero and get rid of the zero to the left of the decimal point. How can I transform, say 0.005000000 into .005? This is necessary due to my file naming convention. Thanks for your recommendations.

UPDATE: Can I use it for already defined shell variables and redefining them? The following code gives me an error.

~/Desktop/MEEP$ printf "%.3f\n" $w bash: printf: 0.005000: invalid number 0,000 

In Ubuntu 14.04.1 LTS 64-bit bash I am declearing floating point variables by multiplying floating point bash variables in bc with scale set to 3; however, I cannot get the number of digits after the decimal point to be zero and get rid of the zero to the left of the decimal point. How can I transform, say 0.005000000 into .005? This is necessary due to my file naming convention. Thanks for your recommendations.

In Ubuntu 14.04.1 LTS 64-bit bash I am declearing floating point variables by multiplying floating point bash variables in bc with scale set to 3; however, I cannot get the number of digits after the decimal point to be zero and get rid of the zero to the left of the decimal point. How can I transform, say 0.005000000 into .005? This is necessary due to my file naming convention. Thanks for your recommendations.

UPDATE: Can I use it for already defined shell variables and redefining them? The following code gives me an error.

~/Desktop/MEEP$ printf "%.3f\n" $w bash: printf: 0.005000: invalid number 0,000 
Tweeted twitter.com/#!/StackUnix/status/547692353583349761
Source Link
Vesnog
  • 689
  • 4
  • 12
  • 29
Loading