如何在执行shell脚本时关闭echo Linux
发布时间:2020-12-16 01:48:10 所属栏目:安全 来源:网络整理
导读:参见英文答案 How to silence output in a Bash script?????????????????????????????????????7个 这是我正在做的一件简单的事情 echo "please enter a command" read x $x checkexitstatus() {...} checkexit status是在其他地方创建的ifloop,只是为了检查
参见英文答案 >
How to silence output in a Bash script?????????????????????????????????????7个
这是我正在做的一件简单的事情 echo "please enter a command" read x $x checkexitstatus() {...} checkexit status是在其他地方创建的ifloop,只是为了检查退出状态 我想知道的是 解决方法
您可以使用Bash重定向:
>命令1> /…/path_to_file =>将stdout重定向到path_to_file. 命令> /…/path_to_file是上一个命令的快捷方式. >命令2> /…/path_to_file =>将stderr重定向到path_to_file 要同时对同一输出执行两种操作:命令> /…/ path_to_file 2>& 1. 2>& 1表示将2(stderr)重定向到1(stdout成为path_to_file). 否则,您还可以存储命令的输出: $var=$(command) # Recent shell like Bash or KSH $var=`command` # POSIX compliant 在此示例中,命令的输出将存储在$var中. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |