shelllings

a practical way to learn shell
git clone https://git.davidvoz.net/shelllings.git
index
logs
tree
license

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