vi 常用技巧

1,取出空行

:1,$g/^$/d

2,去除段首的空格

3,添加多行注释

:2,50 s/^/#/g 在2~50 行首添加 # 号注释

4,取消多行注释

:2,50 s/^#//g 在2~50 行首添加 # 号注释

5,去除微博中的短链接,只用sed语句

cat 团圆饭.sample | sed -n -i '1,$s/http:\/\/t\.cn\/[a-zA-Z0-9]\{7\}//g' 

 

使用java语句:

Pattern pattern = Pattern.compile("http://t.cn/[a-zA-Z0-9_]{7}");
        Matcher matcher = pattern.matcher(str);
        //替换第一个符合正则的数据
        return matcher.replaceAll("");

6,sort中指定分割符号为tab按键

sort -t $'\t' -f 1

7,

posted @ 2014-02-21 10:53  bobo的学习笔记  阅读(240)  评论(0编辑  收藏  举报