2008年12月11日星期四

sed 替换tab

一位仁兄的做法:
$ cat tab.txt 
col1    col2    col3
i am big.
col1 col2 col3

1.2sed脚本
$ cat sedscr.tab 
s/      />/gp

1.3sed替换命令
$sed -nf sedscr.tab tab.txt 
col1>col2>col3
好一点的办法是:
c-v-tab 直接在终端上打出tab 符   
应该还有其他解决方案:
貌似\t 才是正解    来天测一下
------------------------------------------------------
后续:2008-12-14
在o'reilly sed and awk 书详细介绍了sed awk所支持的正则表达式
[:alnum:] Printable characters (includes whitespace) [:alpha:] Alphabetic characters [:blank:] Space and tab characters [:cntrl:] Control characters [:digit:] Numeric characters [:graph:] Printable and visible (non-space) characters [:lower:] Lowercase characters [:print:] Alphanumeric characters [:punct:] Punctuation characters [:space:] Whitespace characters [:upper:] Uppercase characters [:xdigit:] Hexadecimal digits

没有评论: