I’m noticing weird behavior in Bash regarding redirection and can’t explain it. When I type
ls <>a
the current directory’s files print to stdout (Bash shell), the file a is created and is left empty. I would expect an error because no input file was ever specified.
When I type
ls >< a
I get an error (unexpected token ‘<‘). Seems to me that, if the first thing happens, this should attempt to use file a as input to ls. This feels inconsistent.
Doing
ls <>
gives me an error (unexpected token ‘newline’)
ls ><
gives me a different error (unexpected token ‘<‘)
Can anybody explain what’s happening here?
<>is a valid bash operator, not consecutive<and>operators.><isn’t a valid operator, so it does get interpreted as consecutive>and<operators. Check the man page: