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?
Using cat output in osascript in terminal
terminal
Related Question
- Terminal Command to display a single line from a text file in OS X
- Edit (colorized) terminal output before printing
- MacOS – Is it possible to select Terminal output by using keyboard keys
- How to rename osascript in the administrator privileges dialog
- Lock Screen using terminal? Osascript is preventing keystrokes
- How to convert this Applescript to Terminal osascript
- How to properly (quickly) iterate over Reminders using AppleScript/osascript
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, likeecho "Hello world" > /tmp/foo.txt
)