File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,28 +40,27 @@ while [[ $# -gt 0 ]]; do
4040 MODE=" size"
4141 shift
4242 ;;
43- -r | --recursive) # count modifier
43+ -r | --recursive)
4444 RECURSIVE=true
4545 shift
4646 ;;
4747 -[0-9] | --[0-9]-decimals)
48- # Extract just the number from -# or --#
4948 DECIMALS=${1// [!0-9]/ }
5049 if ! [[ $DECIMALS =~ ^[0-9]+$ ]]; then
5150 echo " inventory: invalid number of decimal places"
5251 exit 1
5352 fi
5453 shift
5554 ;;
56- -KB | --kilobytes) # size modifier
55+ -KB | --kilobytes)
5756 NUMBER_FORMAT=" KB"
5857 shift
5958 ;;
60- -MB | --megabytes) # size modifier
59+ -MB | --megabytes)
6160 NUMBER_FORMAT=" MB"
6261 shift
6362 ;;
64- -GB | --gigabytes) # size modifier
63+ -GB | --gigabytes)
6564 NUMBER_FORMAT=" GB"
6665 shift
6766 ;;
@@ -123,7 +122,7 @@ elif [ $MODE = "size" ]; then
123122 SIZE=$( awk -v size=" $FILE_SIZE " -v dec=" $DECIMALS " ' BEGIN { printf "%0." dec "f", size/1000000000 }' )
124123 UNIT=" GB"
125124 fi
126- # Remove trailing .00 if there are no decimal places
125+
127126 if [[ $DECIMALS -eq 0 ]]; then
128127 SIZE=${SIZE% .* }
129128 fi
You can’t perform that action at this time.
0 commit comments