我正在尝试使用 eval 命令来评估评论——我不确定这是否是正确的方法。例子:
i=??
(我在这里想要的是#
, 评论之后的内容,或空白)
somecommand arg1 arg2 $(eval $i) >> file
因此,根据$i
价值,它必须是:
somecommand arg1 arg2 # >> file
从“不打印到文件”开始
或者
somecommand arg1 arg2 >> file
从“打印到文件”开始
一个更清晰的示例脚本:
i=true
somecommand arg1 arg2 >> file1
[some code]
somecommand arg1 arg2 >> file2
[some code]
somecommand arg1 arg2 >> file3
[some code]
And so on...
Run Code Online (Sandbox Code Playgroud)
我希望它只有在$i
它为真时才将输出打印到文件中;或者,正如我最初尝试的那样,eval
将 $i 设为注释并注释“输出到文件”的一段代码。
我问是因为我认为有一种比做这样的事情更优雅的方式:
if $i
then
somecommand arg1 arg2 >> file3
else
somecommand arg1 arg2
fi
Run Code Online (Sandbox Code Playgroud) 不确定是否可以共享我试图获取其来源的网站,但我认为有必要进行更好的解释。如果不是提前,我深表歉意
命令:
curl -k -L -s https://www.mi.com
由于出现以下错误,由于某种原因,输出是二进制数据
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
Run Code Online (Sandbox Code Playgroud)
如何阅读页面 HTML 源代码?谢谢!