Skip to content

Commit

Permalink
Create convert_units.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
schollii authored Nov 10, 2021
1 parent 15f5bde commit cd0acb0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions convert_units.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
convu() {
conv=$( units -f ~/.units.bytes $2 $3 | grep / | cut -f 2 -d " " )
# sometimes the conversion factor is a large number output by
# units in scientific notation so need to convert it to int with printf
echo $(( $1 / $( printf "%.f" $conv ) ))
}

0 comments on commit cd0acb0

Please sign in to comment.