2012-02-10 21:59:57 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
[ -f testing.sh ] && . testing.sh
|
|
|
|
|
|
|
|
#testing "name" "command" "result" "infile" "stdin"
|
|
|
|
|
|
|
|
testing "head, stdin" "head -n 1 && echo yes" "one\nyes\n" "" "one\ntwo"
|
|
|
|
testing "head, stdin via -" "head -n 1 - && echo yes" "one\nyes\n" "" "one\ntwo"
|
|
|
|
testing "head, file" "head input -n 1 && echo yes" "one\nyes\n" "one\ntwo" ""
|
2015-03-29 10:03:46 -07:00
|
|
|
testing "head -number" "head -2 input && echo yes" "one\ntwo\nyes\n" \
|
|
|
|
"one\ntwo\nthree\nfour" ""
|
2012-02-10 21:59:57 -08:00
|
|
|
testing "head, default lines" "head" "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" "" "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12"
|
|
|
|
|
|
|
|
echo "foo
|
|
|
|
bar
|
|
|
|
baz" > file1
|
|
|
|
testing "head, multiple files" "head -n 2 input file1" "==> input <==\none\ntwo\n\n==> file1 <==\nfoo\nbar\n" "one\ntwo\nthree\n" ""
|
|
|
|
rm file1
|
|
|
|
|