shelllings

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

08_cat.sh
1#!/bin/sh
2
3set -eu
4RED="\033[31m"
5GREEN="\033[32m"
6RESET="\033[0m"
7
8cleanup() {
9 [ -f "08_cat" ] && rm 08_cat
10}
11trap cleanup EXIT
12
13failed() {
14 printf "${RED}Failed${RESET}\n"
15 exit 1
16}
17
18output=$(sh exercises/08_cat.sh)
19answer=$(tail -n 50 LICENSE | wc -w)
20
21[ $(wc -w < 08_cat) -eq $answer ] || failed
22
23printf "${GREEN}Passed${RESET}\n"