0

after using

adb shell df

How to parse the text to eliminate spaces under Free column ?

Filesystem             Size   Used   Free   Blksize
/dev                   483M    52K   483M   4096
/mnt/secure            483M     0K   483M   4096
/mnt/asec              483M     0K   483M   4096
/mnt/obb               483M     0K   483M   4096
/system                788M   720M    67M   4096
/data                    1G   513M     1G   4096
/cache                 123M     4M   118M   4096
/mnt/cd-rom              4M     4M     0K   2048
/protect_f               8M     4M     4M   4096
/protect_s               8M     4M     4M   4096

the main goal is to calculate the sum of free space.

M. A.
  • 424
  • 6
  • 21

1 Answers1

0

As there are no language restrictions within your question at this time, in Bash...

adb shell df -BM | awk '{if(NR>1) print $4}'

... should output the fourth column and by using the -BM option with the df command one can avoid headaches when there's partitions with gigabytes or more of available space.

However, do note that df output may vary so I'd suggest looking to the man and --help documentation as there's a --total option that might be easier to deal with...

adb shell df -BM --total | tail -1
S0AndS0
  • 860
  • 1
  • 7
  • 20