#cat a>>a
#cat: 0652-055 a: Source is same as Target. Skipping...
a是同名文件
AIX下会报错。
[study][root][/tmp/liu]#ls
1.sh b c urfile
[study][root][/tmp/liu]#cat -- a>>a
[study][root][/tmp/liu]#ls
1.sh a b c urfile
[study][root][/tmp/liu]#cat a
[study][root][/tmp/liu]#ls -l |grep a
total 0
-rw-r--r-- 1 root system 0 Feb 14 08:54 a
###a为空文档:运行cat -- a>>a后,无报错,命令自动终止并创建a文档。
[study][root][/tmp/liu]#echo a>>a
[study][root][/tmp/liu]#ls -l |grep a
total 0
-rw-r--r-- 1 root system 2 Feb 14 08:55 a
[study][root][/tmp/liu]#ls
1.sh a b c urfile
[study][root][/tmp/liu]#cat -- a>>a
^C[study][root][/tmp/liu]#ls
1.sh a b c urfile
[study][root][/tmp/liu]#ls -l |grep a
total 0
-rw-r--r-- 1 root system 1398862 Feb 14 08:55 a
[study][root][/tmp/liu]#
###a为非空文档:给a插入a字符,运行cat -- a>>a,无报错,强制终止命令,并发现a 文档瞬间撑大。
命令运行后a文档无限自写入,进入死循环。
系统环境:
[study][root][/tmp/liu]#oslevel -s
6100-01-09-1015
[study][root][/tmp/liu]#uname -a
AIX study 1 6 00CCECFB4C00
运行语言:
ksh
PS: 我在LINUX下bash下
[localhost.localdomain][root][/root]#cat -- a>>a
cat: a:输入文件是输出文件
###该命令报错
论坛中在AIX powerpc下测试此命令,同样报错。
$ uname -a
AIX aix 3 5 00C97AC04C00 powerpc unknown AIX
$ echo $0
ksh
$ cat urfile
16
19,20
24,25,26
$ cat urfile >>urfile
cat: urfile: input file is output file
$ cat -- urfile >>urfile
cat: urfile: input file is output file
收起