I've been trying to automate git pulls with a Bash script. To make sure I don't miss the execution results of the script, and yo log these results somewhere for possible reviews if things go wrong, I've added this line to my script :

# Does git pull
`notify-send "Git pull log message" |tee -a "$mylogfile"
# Other stuff

The rest of the script works fine, it does what's expected e.g. perform a git pull automatically. The notification given to notify-send also displays fine on my computer, and I can access it from the notification list.

My problem is what I pipe the notification into (|tee -a $mylogfile). It simply doesn't redirect the notification message to the file $mylogfile. I've also tried :

notify-send "Git pull log message" |tee "$mylogfile"
notify-send "Git pull log message" > "$mylogfile"
notify-send "Git pull log message" >> "$mylogfile"

which don't appear to write anything either. I also ran these commands from both a script and the terminal, same behaviour. The manual page for notify-send is also very short, and doesn't mention anything about how to use the command with file I/O. I've also not found related questions on Stack Exchange, [this one][1] being the closest, but I'm trying to get notify-send output to a file, not give it a file as input.I guess nothing is redirected because there's no output displayed in the terminal, which means nothing is written to stdout.

I guess I could settle for something like

msg="Git pull log message"
notify-send "$msg" && echo "$msg" > "$mylogfile"

which would work by splitting the command in 2 lines and using a variable, but I'd like to keep it to one line and no explicit variable so that only that line in the script pertains to the notification and its logging, and nothing else.

I'm sure I must have missed something obvious. Could you please help me with that? [1]: https://askubuntu.com/questions/216326/can-i-redirect-file-as-input-to-notify-send

2 Answers 2


Actually, in the process of typing out the question, I found this command which inspired me enough to find a solution. Since it might help others in the same situation, and because I couldn't find a duplicate question on this SE site or others, I share it below :

echo "Git pull log message" |tee -a "$mylogfile" |xargs -I% notify-send "%"

The idea is to invert the order of commands. Instead of starting with notify-send, I start with echo and tee to first write to the logfile, because this way, tee also sends the message to stdout. This way, I have something to pipe into notify-send. Using xargs avoids a "No summary specified" error.


Pipe the output of git pull to notify-send without writing a log file:

git pull | xargs -I{} notify-send {}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .