Could someone help me under stand the condition ls /etc/*release 1>/dev/null 2>&1
that's contained in the code:
if ls /etc/*release 1>/dev/null 2>&1; then
echo "<h2>System release info</h2>"
echo "<pre>"
for i in /etc/*release; do
# Since we can't be sure of the
# length of the file, only
# display the first line.
head -n 1 $i
done
uname -orp
echo "</pre>"
fi
I pretty much don't understand any of that line but specifically what I wanted to know was:
- Why dose it not have to use the 'test' syntax i.e.
[ expression ]
? - The spacing in the condition also confuses, is
1>/dev/null
a variable in thels
statement? - what is
2>&1
?
I understand the purpose of this statement, which is; if there exists a file with release in it's name under the /etc/
directory the statement will continue, I just don't understand how this achieves this.
Thanks for you help