I want to display a notification using osascript in terminal, but the text I want to display is stored in a text file. How can I display that text in the notification?
In the Bash shell, you can read in the text of the file using
cat and shove it into a substitution.
osascript -e "display notification \"$(cat /tmp/foo.txt)\" with title \"hello\""
(Obviously put something in
/tmp/foo.txt first, like
echo "Hello world" > /tmp/foo.txt)
Basically you need to read the file content into a variable first. There are several ways to do this, one is
text=$(< TEXTFILE) osascript ... "$text"
Here is the complete soloution to my initial question I posted about:
set listOfCommand to (read POSIX file "path-to/command.txt") tell application "Terminal" do script listOfCommand delay 1 quit end tell set listOfShows to (read POSIX file "path-to/dump.txt") tell application "Safari" display notification listOfShows with title "Downloads:" end tell