经常遇到小shell脚本需要去查资料,现在慢慢地总结一下。
1.将日志输出同时打印到屏幕和日志文件
==方法
使用tee命令实现,参考:
tee - read from standard input and write to standard output and files
==示例:
echo abc |tee ./abc.log
2.if条件判断有多个条件时
==方法
使用and(&&)或者or(||)等
==示例:
if [[ "$answer" == "yes" ]] || [[ "$answer" == "Yes" ]] || [[ "$answer" == "YES" ]] || [[ "$answer" == "Y" ]]; then
<...omitted...>
阅读(569) | 评论(0) | 转发(0) |