Search code examples
bashshellstdoutio-redirectionstderr

stderr not directed properly


the following command:

ls > . 2> error

prints:

bash: .: Is a directory

to the terminal. But since I redirect stderr to 'error' I expect this line to be written into error and not the terminal.


Solution

  • Redirections are done left-to-right, so your stdout redirection fails before your stderr redirection starts. Compare with ls 2> error > .