0

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?

DisplayName
  • 145
  • 4

1 Answers1

0

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.

mfinni
  • 36,144
  • 4
  • 53
  • 86