亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標題: 奇怪的sed [打印本頁]

作者: qzhu    時間: 2004-08-12 02:13
標題: 奇怪的sed
Haven't done much scripting lately.

OS: tru64unix V4.0G, Shell: csh
# which sed
/usr/bin/sed
# echo "a b" | sed 's/ /\t/'
atb
# echo "a b" | sed 's/ /\\\t/'
a\tb

???
I am expecting a TAB between "a" and "b", not "atb" nor "a\tb", what am I doing wrong?
Seems sed won't recognize all escape sequences such as \n,\t,\r,\b ...
Anyone has comment on this? much appreciated.
作者: lightspeed    時間: 2004-08-12 02:38
標題: 奇怪的sed
與 不同系統及版本的 sed 有關.  一般 sed 很可能只有 \  \n  &  三個特殊字符. 如果是這樣,用 " 代替 '

# echo "a b"|sed "s/ /\t/"
作者: zhiguo_luan    時間: 2004-08-12 10:04
標題: 奇怪的sed
好像還是不行,偶的是GNU3.02
作者: lightspeed    時間: 2004-08-12 11:21
標題: 奇怪的sed
GNU 3.02 不支持 \t,  3.02.80 以上可以。

再試一次:

echo "a b"|sed "s/ /`echo \\\t`/"

不行的話, 就升級吧。
作者: zhiguo_luan    時間: 2004-08-12 13:04
標題: 奇怪的sed
OK
作者: qzhu    時間: 2004-08-13 02:30
標題: 奇怪的sed
看樣子在某些版本中如果\t不管用,直接輸入TAB就可以了。

http://www.unixguide.net/unix/sedoneliner.shtml

USE OF '\t' IN SED SCRIPTS: For clarity in documentation, we have used the expression '\t' to indicate a tab character (0x09) in the scripts. However, most versions of sed do not recognize the '\t' abbreviation, so when typing these scripts from the command line, you should press the TAB key instead. '\t' is supported as a regular expression metacharacter in awk, perl, and in a few implementations of sed.





歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2