tail: cannot open `+?` for reading錯誤處理

今天執行一個網管安裝程序,在redhat4.5下正常,在redhat5.2上無法執行報錯如下:

 

  1. [root@db1 ssm]# sh ssm-3.2.1-linux.installer   
  2. tail: cannot open `+22for reading: No such file or directory  
  3.  
  4. zcat: stdin: not in gzip format  
  5. 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’來解決兼容性。
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章