./test2.sh >/dev/null 2>&1
/dev/null:可以理解为linux下的回收站;
通过符号“>”把标准输出进行重定向;
2>&1:是把出错输出也重定向输出;
[root@abc home]# ./test2.sh t.txt >/dev/null 2>&1
[root@abc home]# ./test2.sh t22.txt >/dev/null 2>&1
[root@abc home]# ./test2.sh t22.txt >/dev/null
[root@abc home]#
[root@abc home]# ./test2.sh t.txt >/dev/null
[root@abc home]# ./test2.sh t999.txt >/dev/null
ls: cannot access t999.txt: No such file or directory
[root@abc home]#
[root@abc home]# ./test2.sh t.txt >/dev/null 2>&1
[root@abc home]# ./test2.sh t999.txt >/dev/null 2>&1
[root@abc home]#
[root@abc home]# cat test2.sh
#!/bin/shif [ $# != 1 ]; then
echo "$0 <file>"
exit
fi
file=$1
ls -l $file
[root@abc home]#