【问题标题】:not able to send multi string/ a sentence as a body in terminal notifier无法在终端通知程序中发送多字符串/句子作为正文
【发布时间】:2018-03-11 18:26:28
【问题描述】:

我想使用终端通知器在桌面通知中发送“多字符串/句子”作为消息

通过终端很容易,它的工作原理如下

命令:

terminal-notifier -title 'testing' -message 'multi string with spaces'

输出

但是当我通过 shell 脚本做同样的事情时,它不会工作:(

shell 脚本: msg="multi string with space" echo $msg terminal-notifier -title 'testing' -message $msg

输出

所以基本上它不会占用空格后的单词/字符...

有什么想法/答案吗?

【问题讨论】:

    标签: shell terminal scripting notifications desktop-application


    【解决方案1】:

    你需要引用变量!

    msg="multi string with space"
    echo "$msg"
    terminal-notifier -title 'testing' -message "$msg"
    

    “双引号”每个包含空格/元字符和每个扩展的文字:"$var""$(command "$var")""${array[@]}""a & b"。将'single quotes' 用于代码或文字$'s: 'Costs $5 US'ssh host 'echo "$HOSTNAME"'。见
    http://mywiki.wooledge.org/Quotes
    http://mywiki.wooledge.org/Arguments
    http://wiki.bash-hackers.org/syntax/words

    【讨论】:

    • Queno,感谢您的链接和详细解释:)
    • 我更喜欢 Gilles,但 up2u ;) 不客气(或至少 Quenot
    • 对不起@Gilles,我很高兴得到我的问题的解决方案,我错过了:)
    猜你喜欢
    • 2022-12-24
    • 2013-02-11
    • 2016-02-17
    • 2021-01-31
    • 2016-12-13
    • 1970-01-01
    • 2019-11-12
    • 2015-03-15
    • 2017-07-16
    相关资源
    最近更新 更多