Been reading on stdin, stdout and stderr and encounter 2 questions, hope gurus here can advise.
0 = stdin
1 = stdout
2 = stderr
Code:
Sun Dec 21 03:53:42 SGT 2014 > cat test5.sh #!/bin/bash echo "Please enter value for name :" read name echo "Your name is $name." echo "Next echo will be a syntax error" ehco
Code:
Sun Dec 21 03:53:46 SGT 2014 > test5.sh 1> output.txt 2> error.txt Noob Sun Dec 21 03:54:56 SGT 2014 > cat output.txt Please enter value for name : Your name is Noob. Next echo will be a syntax error Sun Dec 21 03:55:23 SGT 2014 > cat error.txt /home/alan/scripts/test5.sh: line 8: ehco: command not found Sun Dec 21 03:55:26 SGT 2014 >
Which so far all is good and the correct way to output everything including error to a single file is
Code:
Sun Dec 21 03:59:14 SGT 2014 > test5.sh > output.txt 2>&1
Q1) How is a command being interpreted in linux , the sequence in which it is interpreted ? from left to right ? right to left ?
Shouldn't it be
Code:
test5.sh 2>&1 1>output.txt or test5.sh 2>&1>output.txt ?
Regards,
Noob