此问题在此处已有答案:
How do I set a variable to the output of a command in Bash?(15个答案)
23天前关闭。
#!/bin/sh
#Saying the system time out loud
time= date +"%T"
say The current time now is, $time. Bye.
剧本是打印时间,不是说时间。
此问题在此处已有答案:
How do I set a variable to the output of a command in Bash?(15个答案)
23天前关闭。
#!/bin/sh
#Saying the system time out loud
time= date +"%T"
say The current time now is, $time. Bye.
剧本是打印时间,不是说时间。
4条答案
按热度按时间lawou6xi1#
您不需要为变量赋值,因为您可以像这样包含
date
的输出fd3cxomn2#
试着像这样使用HereDoc ...
2lpgd9683#
好的,这个成功了。谢谢。:)感谢你的帮助!
0s0u357o4#
time= date +"%T"
您希望将
time
设置为date
命令的stdout,因此需要$(date +%T)
(%T
两边的双引号不是必需的,因为%
在此上下文中没有特殊含义)。打印时间,而不是说出来。”
修正你的语法,它对我很有效,最近把时间说成了“214627”,例如。