Using the mhelper binary, bc, and other expressions, we can begin the recipe:
- Begin by opening a terminal and an editor to create a new script called mathexp.sh with the following contents:
#!/bin/bash# Retrieve file system information and remove headerTARBALL="archive.tar.gz"CURRENT_PART_ALL=$(df --output=size,avail,used /home -B 1M | tail -n1)# Iterate through and fill arrayIFS=' ' read -r -a array <<< $CURRENT_PART_ALL# Retrieve the size of the contents of the tarballCOMPRESSED_SZ=$(tar tzvf "${TARBALL}" | sed 's/ \+/ /g' | cut -f3 -d' ' | sed '2,$s/^/+ /' | paste -sd' ' | bc)echo "First inspection - is there enough space?"if [ ${array[1]} -lt ${COMPRESSED_SZ} ]; then echo "There is not enough space to decompress the ...