Shorter way to assign a default value to the standard output stream I have this code :

tr ' ' '\n'|sort -n|head -1


The code is pretty simple, it takes a list of integer in the standard input stream (like 5 9 8 7 5 2 -12 -30), it sort the integers and display only the first integer. But i need to ouput 0 if the given list is empty. And i can't find a short way to that. I have a solution with a ternary operator and a echo 0, but i feel i can do far better. I just need to replace the input stream by 0 if this stream is empty.

Sidenote : I don't need to call read to get the user input. The program is called with the input stream directly like cmd &lt; 1 5 6 -20 45

Here my current code :

read l
[ -n "$l" ]&amp;&amp;echo $l|tr ' ' '\n'|sort -n|head -1||echo 0
37 33 32 bytes

tr \  \\n|sort -n|sed s/^$/0/\;q


Edit: Saved 4 bytes thanks to @DigitalTrauma.