`
whitesock
  • 浏览: 478660 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

Several Frequently Used Commands

阅读更多

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)}

 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics