Answer 1) For float calculations you will have to delegate the task to other programs such as bc.
For example:
echo "scale=3;20.8/4 | bc
5.200
For more options you can check:
https://unix.stackexchange.com/questions/40786/how-to-do-integer-float-calculations-in-bash-or-other-languages-frameworks
https://unix.stackexchange.com/questions/76060/perform-floating-point-arithmetic-in-shell-script-variable-definitions
How do I use floating-point division in bash?
to find out filenames having float numbers you can use regular expressions along with find
command:
$touch r3.987.txt
$find . -regextype sed -regex ".*/r[0-9]\.[0-9]\{3\}.txt$"
./r3.987.txt
regular expression type is that of sed, find . means find in current directory
*/ => to check only for filenames only and skip the leading directory structure
[0-9] matches any digit in range 0 to 9
\. means match a dot
[0-9]\{3\} means [0-9]{3} to match exactly 3 digits and each digit can be in range 0-9
and finally ending in .txt
as for Answer 2) you can get that float value as a string by looping through the output of the find command
$for filename in "$(find . -regextype sed -regex ".*/r[0-9]\.[0-9]\{3\}.txt$")"
> do
> echo "Filename is $filename"
> floatValueAsString=$(echo "$filename" | egrep -o '[0-9]\.[0-9]{3}')
> echo "Float value as string is $floatValueAsString"
> done
Filename is ./r3.987.txt
Float value as string is 3.987