[Solved] Why does this unix shell code work like this? [closed]


The shell first processes input/output redirections like > 5 and attaches the relevant file handles to the file it opens (5 in this case).

It also expands * into the matching files in the current directory. So what you end up with is:

echo 2 <<ALL YOUR FILES>> is a valid inequality

where the output is sent to your previously opened file.

If you want the literal string to be output, you need to tell the shell not to do its normal interpretation:

echo '2 * 3 > 5 is a valid inequality'

2

solved Why does this unix shell code work like this? [closed]