Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified episodes/data/shell-lesson-data.zip
Binary file not shown.
18 changes: 15 additions & 3 deletions shell-lesson-data/north-pacific-gyre/goodiff.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 20 additions & 4 deletions shell-lesson-data/north-pacific-gyre/goostats.sh
Original file line number Diff line number Diff line change
@@ -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"