【发布时间】:2021-01-13 07:17:05
【问题描述】:
我为 mac OS 中的 5 秒显示通知创建了一个 bash 脚本。
#!/bin/bash
arr[0]="0"
arr[1]="1"
arr[2]="2"
arr[3]="3"
arr[4]="4"
arr[5]="5"
arr[6]="6"
while true; do
rand=$[$RANDOM % ${#arr[@]}]
text=${arr[$rand]}
osascript -e 'display notification '"$text"' with title "hello"'
sleep 5
done
但显示带有标题 hello 和描述 $text 的通知。 如何在这个命令中使用 $text 变量?
【问题讨论】:
-
当你用
osascript包围你的osascript行时你看到了什么?祝你好运。 -
@RasoulMiri : 如果不涉及 zsh,为什么要标记 zsh?
标签: bash macos sh zsh oh-my-zsh