Home >Operation and Maintenance >Linux Operation and Maintenance >Classic Thirteen Questions about Shell Scripts You Should Know
8. () and ${}. What’s the difference?
9. and *?
10. What is the difference between && and ||?
11. What is the difference between > and 0c4af0acd46919dd0ff35ca00a788b6e 与 c01b8772d0f6397290d6d9199e3ce834 来改变送出的数据信道(stdout, stderr),使之输出到指定的档案。
ls my.file no.such.file 1> file.out 2>file.err # 2>&1 就是将stderr并进stdout做输出 ls my.file no.such.file 1> file.out 2>&1 # /dev/null 空 ls my.file no.such.file >/dev/null 2>&1 cat < file > file # 在 IO Redirection 中,stdout 与 stderr 的管道会先准备好,才会从 stdin 读进资料。 # 也就是说,在上例中,> file 会先将 file 清空,然后才读进 < file , # 但这时候档案已经被清空了,因此就变成读不进任何数据了
# if echo -n "Do you want to continue?(Yes/No):" read YN if [ "$YN"=Y -o "$YN"=y -o "$YN"="Yes" -o "$YN"="yes" -o "$YN"="YES"];then echo "continue" else exit 0 fi # case echo -n "Do you want to continue?(Yes/No):" read YN case "$YN" in [Yy]|[Yy][Ee][Ss]) echo "continue" ;; *) exit 0 esac
# for for ((i=1;i<=10;i++)) do echo "num is $i" done # while num=1 while [ "$num" -le 10 ]; do echo "num is $num" num=$(($num + 1)) done # until num=1 until [ "$num" -gt 10 ]; do echo "num is $num" num=$(($nu + 1)) done
The above is the detailed content of Classic Thirteen Questions about Shell Scripts You Should Know. For more information, please follow other related articles on the PHP Chinese website!