六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 36|回复: 0

Several Frequently Used Commands

[复制链接]

升级  45.33%

34

主题

34

主题

34

主题

秀才

Rank: 2

积分
118
 楼主| 发表于 2013-2-4 13:29:12 | 显示全部楼层 |阅读模式
sed '/^\s*$/d' a.txt # delete ALL blank lines
sed '/./,$!d' a.txt # delete all leading blank lines at top of file
 
sed '=' a.txt | sed 'N;s/\n/\t/' # cat -n a.txt
sed '/./=' a.txt | sed '/./N; s/\n/\t/' # number each not blank line of file
 
sed '1!G;h;$!d' a.txt # reverse order of lines
sed '/./,$!d' a.txt # delete all leading blank lines at top of file
sed '$!N; /^\(.*\)\n\1$/!P; D' a.txt # delete duplicate, consecutive lines
 
gawk '$1~/[0-9].*/{total += $2} END{print total}' a.txt
gawk 'BEGIN {"cat c.txt | wc -l"|getline n} n>10 {print}' a.txt
ls | gawk -F. '{system("mv " $0 " " sprintf("%03d", $1) "." $2)}
<div class="O1"> 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表