shelllings

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

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