diff --git a/episodes/data/shell-lesson-data.zip b/episodes/data/shell-lesson-data.zip index 669359dec..4859b9506 100644 Binary files a/episodes/data/shell-lesson-data.zip and b/episodes/data/shell-lesson-data.zip differ diff --git a/shell-lesson-data/north-pacific-gyre/goodiff.sh b/shell-lesson-data/north-pacific-gyre/goodiff.sh index 4e7f30b7c..9074c75d2 100644 --- a/shell-lesson-data/north-pacific-gyre/goodiff.sh +++ b/shell-lesson-data/north-pacific-gyre/goodiff.sh @@ -1,13 +1,25 @@ +#!/bin/bash +# Incomplete goo comparator by Nelle Nemo. + # check for the right number of input arguments if [ $# -ne 2 ] then - echo "goodiff file1 file2" - echo "call goodiff with two arguments" + echo "call goodiff with two arguments:" + echo " $0 file1 file2" exit 1 fi +# check read permissions +if [ ! -f "$1" ] +then + echo "error reading $1" + exit 2 +elif [ ! -f "$2" ] +then + echo "error reading $2" + exit 2 +fi -# difference of two input files # demo version, just return a random number or "files are identical" if [ "$1" == "$2" ] then diff --git a/shell-lesson-data/north-pacific-gyre/goostats.sh b/shell-lesson-data/north-pacific-gyre/goostats.sh index a3f06626e..d47e46d6d 100644 --- a/shell-lesson-data/north-pacific-gyre/goostats.sh +++ b/shell-lesson-data/north-pacific-gyre/goostats.sh @@ -1,10 +1,26 @@ +#!/bin/bash +# goostats.sh: a research script by Nelle Nemo +# Analyze "goo" input data and write "stats" to result file. + # check for the right number of input arguments if [ $# -ne 2 ] - then - echo "goostats file1 file2" - echo "call goostats with two arguments" +then + echo "call goostats with two arguments:" + echo " $0 input_file result_file" exit 1 fi +# check if files already exist (good for $1, bad for $2) +if [ ! -a "$1" ] +then + echo "error reading input: $1" + exit 2 +elif [ -a "$2" ] +then + echo "error writing result: $2" + exit 2 +fi + +# run the numbers sleep 2 -head -n 3 $1 | cut -d , -f 1 | sort | uniq > $2 +head -n 3 "$1" | cut -d , -f 1 | sort | uniq > "$2"