Shell – A command that generates both standard error and output

io-redirectionshell-scriptstderrstdout

I want to do some troubleshooting on my bash script. Is there a short and simple command that generates both stdout and stderr so that I can use 2>&1 on it? Sorry if this looks trivial, but I just can't think of one at the moment.

Best Answer

A simple approach would be to use ls to list actual and imaginary files:

ls . *.blah

This assumes that there are visible files in the working directory and that you don't have any files that end in .blah1


1. ...and if you do, we won't judge you.