0

I have following line in the script:

maim -s | tee $fname > last.png

maim -s takes screenshot and returns 0 if it was taken succesfully or 1 if it was cancelled. The problem is, if it returns 0, it pipes zero bytes anyway so after cancelling i have two empty files $fname and last.png.

I want to redirect output to /dev/null if maim -s returns 0 right on the place, without writing to temporary file and copying it to $fname and last.png if it isn't empty.
How do I do that?

0 Answers0