ls
Cargo\.toml

(ls)
Cargo\.toml

ls foo.txt

ls.*foo\.txt.*such file
ls foo.txt | wc
^0.*0.*0$
^$
ls foo.txt 2>&1 | wc
^1.*\d+.*\d+$

echo hi
hi

echo foo bar
foo bar

echo foo | wc
1\s+1\s+4

echo foo 1>&2 | wc
0\s+0\s+0

echo foo >&2 | wc
0\s+0\s+0

echo foo 2>&1 | wc
1\s+1\s+4

echo foo > bar | wc
0\s+0\s+0

echo foo>bar | wc
0\s+0\s+0

echo foo> bar | wc
0\s+0\s+0

echo foo >bar | wc
0\s+0\s+0

echo foo > bar


cat bar
^foo$

echo foo>bar


cat bar
^foo$

echo foo> bar


cat bar
^foo$

sort < bar
^foo$

echo foo >bar


cat bar
^foo$

echo 123 >> bar


wc bar
^2\s+2\s+8\s+bar$

rm -f bar  # clean up


touch "foo'bar.txt"


rm foo\'bar.txt


echo foo > /dev/null


echo foo bar baz | awk -F '[ \"]+' '{print $3, $2, $1}'
^baz bar foo$

ls | cat
Cargo\.lock

ls | cat | cat | more
Cargo\.toml

echo foo`which ls`
^foo/.*/ls$

echo --author='Hugo Wang <w@mitnk.com>'
--author=Hugo Wang <w@mitnk.com>

VAR_RANDOM_135=123  # define a shell variable


echo $VAR_RANDOM_135  # test the shell variable
^123$

echo ${VAR_RANDOM_135}  # test the shell variable
^123$

echo 'echo $VAR_RANDOM_135' > foo.sh


sh foo.sh  # child cannot see $VAR_RANDOM_135


VAR_RANDOM_135=357 sh foo.sh  # but can see its prefixing envs
^357$

A=1 VAR_RANDOM_135="abc 123" sh foo.sh  # testing quotes
^abc 123$

VAR_RANDOM_135=a${HOME}c sh foo.sh
^a/.*c$

VAR_RANDOM_135="a${HOME}c" sh foo.sh
^a/.*c$

# VAR_RANDOM_135='a${HOME}c' sh foo.sh  # TODO: should not expend envs with strong quotes


echo $VAR_RANDOM_135  # the above inline env settings won't change the shell variable
^123$

rm -f foo.sh  # clean up


echo f{oo,pp}1.txt
^foo1.txt fpp1.txt$

echo sp{el,il,al}l
^spell spill spall$

echo `echo foo bar | awk '{print $2, $1}'`
^bar foo$

echo `echo yoo`
yoo

echo `echo yoo` foo `echo hoo`
^yoo foo hoo$

echo $(echo yoo)
^yoo$

echo "$(echo yoo)"
^yoo$

echo '$(echo yoo)'
^..echo yoo.$

echo $(echo yoo) foo $(echo hoo)
^yoo foo hoo$

echo A$(echo foo)B
^AfooB$

echo A$(echo foo | cat)B
^AfooB$

echo A$(echo foo | awk '{print $1}')B
^AfooB$

echo A`echo foo`B
^AfooB$

echo A`echo foo bar | awk '{print $2, $1}'`B
^Abar fooB$

touch ftest{1,3,5}.txt bbbb.txt


ls -1 | grep 'ftest.*txt' | wc -l  # make sure created 3 ftest files
^3$

rm ftest*.txt bbbb.txt  # test filename expand


touch foo\ bar.txt baz.txt


rm foo*.txt baz.txt  # should rm files without errors


echo $$
^[0-9]+$

echo $?
^0$

echo "result is $(2 ^ 35 + 1.1 - 2 * 2 + 3.02345 + 16 / 8)"
^result is 34359738370.12345$

echo "result is `(1 + 1) ^ 31`"
^result is 2147483648$

echo "result is $(((1 + 1) ^ 31) - (3 - 2))"
^result is 2147483647$

