今天执行一个网管安装程序,在redhat4.5下正常,在redhat5.2上无法执行报错如下:
- [root@db1 ssm]# sh ssm-3.2.1-linux.installer
- tail: cannot open `+22' for reading: No such file or directory
- zcat: stdin: not in gzip format
- ssm-3.2.1-linux.installer: line 13: cd: /tmp/selfinstaller31577.tmp/*: No such file or directory
解决tail出错方法: export _POSIX2_VERSION=199209。
# tail +2 wln.txt
tail: cannot open `+2` for reading: No such file or directory
==> wln.txt <==
It is sunny today,
you are an industrious boy,
give the room a good sweep.
# tail –n +2 wln.txt
you are an industrious boy,
give the room a good sweep.
新版本POSIX用’tail +2’命令不能正确显示文件前两行内容,必须用’tail –n +2’命令才行。
为了解决不同版本的 POSIX 标准的兼容性问题,使得 GNU utilities 能和不同版本的 POSIX 标准工作,Linux 系统引入了环境变量’_POSIX2_VERSION’,这个变量的格式是 YYYYMM,表示 POSIX 标准采用的年代和月份。
当前’_POSIX2_VERSION’有两个值:
‘199209’ 代表 POSIX 1003.2-1992
‘200112’ 代表 POSIX 1003.1-2001
设置用法:
export _POSIX2_VERSION=199209
取消设置:
unset _POSIX2_VERSION
如果你有旧版本的应用程序和脚本想移植到采用新版本 POSIX 标准的系统上运行,比如’tail +10’,’sort +1’等,你就能通过设置环境变量’_POSIX2_VERSION=199209’来解决兼容性。