I have du -sh
output saved to txt file:
2.1G /home/x/sample/2GB/
101M /home/x/sample/100MB/
...
What I want is to multiply each value in the first column by a value taken from variable depending on the unit. So if for instance unit is G then multiply by $G and append the the result at the end of each line. How to do this in Bash?
It sounds like you're trying to get the bytes, so instead of using
-h
(which is a shortcut for--human-readable
), just don't use it.du -s
will get you the summarized byte count.