shelllings

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

commit 6a98e5b91a4448ef609f547806f43d5862fb3cff
parent d3d5de8a2fff6e399cfc6eb52dcfbda4910b504e
Author: David Voznyarskiy <31452046-davidvoz@users.noreply.gitlab.com>
Date:   Tue, 13 Jan 2026 11:44:03 -0800

exercise tar handling added

Diffstat:
Aexercises/30_tar.sh | 8++++++++
Atests/30_tar.sh | 28++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/exercises/30_tar.sh b/exercises/30_tar.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# tar is another GNU compression tool that will be more likely used. +# It's more often used in compression of multiple files and folders. +# Same as before, using the --help option, try to find the problem with +# the command below. Don't worry about deleting the .tar.gz file. + +tar -czf exercises/ tests/ shelllings.sh shelllings.tar.gz diff --git a/tests/30_tar.sh b/tests/30_tar.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -eu +RED="\033[31m" +GREEN="\033[32m" +RESET="\033[0m" + +cleanup() { + rm *.tar.gz +} +trap cleanup EXIT + +failed() { + printf "${RED}Failed${RESET}\n" + exit 1 +} + +sh exercises/30_tar.sh || failed + +[ -s shelllings.tar.gz ] || failed + +file_size=$(du -s shelllings.tar.gz | awk '{print $1}') + +tar -czf check.tar.gz exercises/ tests/ shelllings.sh + +diff check.tar.gz shelllings.tar.gz || failed + +printf "${GREEN}Passed${RESET}\n"