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 # cannot both do redirect and capture output
^1.*\d+.*\d+$
echo hi
hi
echo foo bar
foo bar
echo foo | wc
1\s+1\s+4
echo foo 1>&2 | wc # cannot both do redirect and capture output
0\s+0\s+0
echo foo >&2 | wc # cannot both do redirect and capture output
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>
FOO=123 # define a shell variable
echo $FOO # test the shell variable
^123$
echo ${FOO} # test the shell variable
^123$
echo 'echo $FOO' > foo.sh
sh foo.sh # child cannot see $FOO
FOO=357 sh foo.sh # but can see its prefixing envs
^357$
A=1 FOO="abc 123" sh foo.sh # testing quotes
^abc 123$
FOO=a${HOME}c sh foo.sh
^a/.*c$
FOO="a${HOME}c" sh foo.sh
^a/.*c$
# FOO='a${HOME}c' sh foo.sh # TODO: should not expend envs with strong quotes
echo $FOO # 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$