shelllings

a practical way to learn shell
git clone https://git.davidvoz.net/shelllings.git
Log | Files | Refs | README | LICENSE

30_tar.sh (432B)


      1 #!/bin/sh
      2 
      3 set -eu
      4 RED="\033[31m"
      5 GREEN="\033[32m"
      6 RESET="\033[0m"
      7 
      8 cleanup() {
      9 	rm *.tar.gz
     10 }
     11 trap cleanup EXIT
     12 
     13 failed() {
     14 	printf "${RED}Failed${RESET}\n"
     15 	exit 1
     16 }
     17 
     18 sh exercises/30_tar.sh || failed
     19 
     20 [ -s shelllings.tar.gz ] || failed
     21 
     22 file_size=$(du -s shelllings.tar.gz | awk '{print $1}')
     23 
     24 tar -czf check.tar.gz exercises/ tests/ shelllings.sh
     25 
     26 diff check.tar.gz shelllings.tar.gz || failed
     27 
     28 printf "${GREEN}Passed${RESET}\n"