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.
Take the 2-minute tour
×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
|
|
||||
|
A simple approach would be to use
This assumes that there are visible files in the working directory and that you don't have any files that end in
|
|||||
|
|
Just write a subshell which sends to
For proof that it works:
This will create files |
||||
|
|
To guaranteed stdout written before stderr:
|
||||
|
|
|
You can write a function to use later:
Then:
|
|||
|
|



ls . *blah(assuming you have some visible files in the current directory and don't have one ending inblah)... – jasonwryan 2 days ago