Answer the question
In order to leave comments, you need to log in
How to cut off zeros in a number?
I need to check the same data from different sources. The output in each looks a little different. For example: in one case, after the decimal point there are numbers (6 pieces) 27.970000, and in the other case, the entry is 27.97; How to remove extra zeros (I take a variable with extra zeros from a file)?
I made up something like this
p=27.978440
echo "$p"
p=$(echo "$p" | cut -d . -f 2 )
tmpp=`echo "$p" | grep 0`
while [ -n "$tmpp" ];do
p=${p%$*0}
tmpp=`echo "$p" | grep [0]`
done
Answer the question
In order to leave comments, you need to log in
Converting to number and comparing between numbers not working?
In general, as soon as the script starts to get complicated, I switch to Python or Lua.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question