hieuhtr / Blog

Don’t be lazy. Don’t make excuses. No one cares. Work fucking harder.
Other
6 stars 2 forks source link

Wrap output of bash script to file #42

Open hieuhtr opened 7 years ago

hieuhtr commented 7 years ago

I want to write all output of bash script to a file, how to do that?

Inside this script

{
 } &> /path/to/log/file

Or outside of this script

❯❯ ./yourscript.sh > output.txt

Example:

❯❯ cat MacNotification.sh
#!/bin/bash
{
echo "Test output"
/usr/bin/osascript -e 'display notification "Ngồi thẳng lưng + uống nước" with title "Suggestion"'
} &> /Users/admin/Documents/Tools/output.log