Edit
As mentioned by chepner in the comments below, I naively misunderstood the bc programming and actually can view the created directories with
ls -a
This problem was solved elsewhere (link below), but I thought I'd include my own problem to help round out the question with background context. One can also just skip to the question further below.
Background
I have the following:
#!/bin/bash
##############################################################################
odir=$PWD
for (( i=0; i<=5; i++ )) ;
do
R=$(echo "scale=2;0.8+(0.1*$i)" |bc -l)
R1=$(echo "scale=2;0.5*($R)" |bc -l)
mkdir -p $odir/$R/rhf/
cd $odir/$R/rhf/
cp $odir/x.inp $odir/run
done
My output creates directories:
1.0 1.1 1.2 1.3
Directories 0.8 and 0.9 are not made. Therefore my problem involves the variable R:
R=$(echo "scale=2;0.8+(0.1*$i)" |bc -l)
Directories with a "leading zero" (0.8 and 0.9) are not being printed.
Solution
This problem was solved in another question here.
In particular, for those interested in the solution, adapted from the second response in the link from potong, is:
R=$(echo "scale=2;x=0.1 + 0.1; if(x<1) print 0; x" | bc
Question
I was wondering if there's any particular reason why bc cannot print the leading zero. Is it a bug, or does it result from something more fundamental? As a nooby in programming, is this error common and something I can expect to encounter again in the future?
Thank you.