Difference between >name 2>&1
and 1>name 2>name
# The result of “main.sh” is
yundongx@zvv2x:/tmp$ bash main.sh
==========1>name 2>name===============
find: �/media/
/media/cdrom
/media/yundongx
/media/apt
======================================
==========1>name 1>&2=================
/root/
find: ‘/root/’: Permission denied
/media/
/media/cdrom
/media/yundongx
/media/apt
======================================
## As you can see, the output order between the `1>name 2>name` and `1>name 1>&2` is different.
#!/bin/bash
#
# Author: bwangel<bwangel.me@gmail.com>
# Date: Mar,20,2017 20:42
## Run this script as a non-root user
find /root/ /media/ -maxdepth 1 1>/tmp/file1 2>/tmp/file1
echo "==========1>name 2>name==============="
cat /tmp/file1
echo "======================================"
find /root/ /media/ -maxdepth 1 1>/tmp/file2 2>&1
echo "==========1>name 1>&2================="
cat /tmp/file2
echo "======================================"