Open HenrikBengtsson opened 3 years ago
I've fixed these issues in the develop
(sic!) branch.
stat --printf="%s"
produces different output compared to ls -sh
Test:
$ stat --printf="%s" lg3-status
14998(base)
$ ls -sh lg3-status
15K lg3-status
Interesting, I cannot reproduce that (base)
suffix;
On TIPCC:
[henrik@cclc01 ~/repositories/UCSF-CostelloLab/LG3_Pipeline-develop/bin]$ pwd
/home/henrik/repositories/UCSF-CostelloLab/LG3_Pipeline-develop/bin
[henrik@cclc01 ~/repositories/UCSF-CostelloLab/LG3_Pipeline-develop/bin]$ size=$(stat --printf="%s" lg3-status)
[henrik@cclc01 ~/repositories/UCSF-CostelloLab/LG3_Pipeline-develop/bin]$ echo "size='$size'"
size='14841'
[henrik@cclc01 ~/repositories/UCSF-CostelloLab/LG3_Pipeline-develop/bin]$ which stat
/usr/bin/stat
[henrik@cclc01 ~/repositories/UCSF-CostelloLab/LG3_Pipeline-develop/bin]$ stat --version | head -1
stat (GNU coreutils) 8.4
On C4:
[henrik@c4-dev3 bin]$ pwd
/c4/home/henrik/repositories/UCSF-CostelloLab/LG3_Pipeline/bin
[henrik@c4-dev3 bin]$ size=$(stat --printf="%s" lg3-status)
[henrik@c4-dev3 bin]$ echo "size='$size'"
size='14841'
[henrik@c4-dev3 bin]$ which stat
/usr/bin/stat
[henrik@c4-dev3 bin]$ stat --version | head -1
stat (GNU coreutils) 8.22
Are you running some other version of stat
?
On C4
[bin] $ which stat
/usr/bin/stat
[bin] $ size=$(stat --printf="%s" lg3-status)
[bin] $ echo $size
14998
The (base) suffix comes from anaconda... So it works as it supposed to, but what I want is "human" format (15K), looks nicer..
[bin]$ size=$(ls -sh lg3-status)
[bin]$ echo $size
15K lg3-status
... I want is "human" format (15K), looks nicer..
How critical is that? In order to get that, one needs to depend on also numfmt
as in:
size=$(numfmt --to=si $(stat --printf="%s" lg3-status))
echo "size=${size}"
#> size=15K
PS. Note that ls -sh
may not safe for other reasons too, e.g. one probably needs to use ls -1 -sh
to handle "too many" files.