Using cat output in osascript in terminal

terminal

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?

Best Answer

In the Bash shell, you can read in the text of the file using cat and shove it into a substitution.

Something like:

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)