免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1437 | 回复: 0

[文本处理] yunle awk [复制链接]

论坛徽章:
6
程序设计版块每日发帖之星
日期:2016-05-11 06:20:00操作系统版块每日发帖之星
日期:2016-05-12 06:20:00每日论坛发贴之星
日期:2016-05-12 06:20:00操作系统版块每日发帖之星
日期:2016-05-14 06:20:00程序设计版块每日发帖之星
日期:2016-05-31 06:20:00每日论坛发贴之星
日期:2016-05-31 06:20:00
发表于 2018-03-16 11:48 |显示全部楼层
# ༺ ༻   # ➜  cat f3-1.xy;cat f3-2.xy                                                                                                
250 #打印如果它包含AAA或BBB或CCC
65字或更长的255 #只打印线
不超过65个字符的259 #只打印线
264 #打印部分文件从正则表达式到文件结束
268 #打印部分文件基于线数(线8-12,包容)
273 #打印行数52
279 #开始3行,每第七行
284 #打印部分文件的两个正则表达式之间(含)
289 #打印所有文件除2正则表达式之间的部分
293 #删除复制,从一个文件连续行(模仿“ 唯一性”)。
保持295 #第一行集合中的重复行,其余部分被删除。
299 #删除复制,从一个文件中不连续的线。注意不要
301 #溢出保留空间的缓冲器的大小,否则使用GNU sed。
305 #删除重复行的所有行(模仿“ uniq -d”)。
309 #删除一个F的前10行
   250      # print paragraph if it contains AAA or BBB or CCC
   255      # print only lines of 65 characters or longer
   259      # print only lines of less than 65 characters
   264      # print section of file from regular expression to end of file
   268      # print section of file based on line numbers (lines 8-12, inclusive)
   273      # print line number 52
   279      # beginning at line 3, print every 7th line
   284      # print section of file between two regular expressions (inclusive)
   289      # print all of file EXCEPT section between 2 regular expressions
   293      # delete duplicate, consecutive lines from a file (emulates "uniq").
   295      # First line in a set of duplicate lines is kept, rest are deleted.
   299      # delete duplicate, nonconsecutive lines from a file. Beware not to
   301      # overflow the buffer size of the hold space, or else use GNU sed.
   305      # delete all lines except duplicate lines (emulates "uniq -d").
   309      # delete the first 10 lines of a file
   313      # delete the last line of a file
   317      # delete the last 2 lines of a file
   321      # delete the last 10 lines of a file
   329      # delete every 8th line
   334      # delete lines matching pattern
   338      # delete ALL blank lines from a file (same as "grep '.' ")
   343      # delete all CONSECUTIVE blank lines from file except the first; also
   345      # deletes all blank lines from top and end of file (emulates "cat -s")
   351      # delete all CONSECUTIVE blank lines from file except the first 2:
   355      # delete all leading blank lines at top of file
   359      # delete all trailing blank lines at end of file
   364      # delete the last line of each paragraph


# [ /home/soio/1bs/awks ] {2018-03-16 11:45:36} : 1521171936:0;
# ༺ ༻   # ➜  awk 'NR==FNR{a[$1]=$0; next} { if ($1 in a){b[$1] = $0}} END {for (i in a){ print a[i]; print b[i]   }}' f3-1.xy f3-2.xy
不超过65个字符的259 #只打印线

65字或更长的255 #只打印线

保持295 #第一行集合中的重复行,其余部分被删除。

250 #打印如果它包含AAA或BBB或CCC
   250      # print paragraph if it contains AAA or BBB or CCC
264 #打印部分文件从正则表达式到文件结束
   264      # print section of file from regular expression to end of file
268 #打印部分文件基于线数(线8-12,包容)
   268      # print section of file based on line numbers (lines 8-12, inclusive)
273 #打印行数52
   273      # print line number 52
279 #开始3行,每第七行
   279      # beginning at line 3, print every 7th line
284 #打印部分文件的两个正则表达式之间(含)
   284      # print section of file between two regular expressions (inclusive)
289 #打印所有文件除2正则表达式之间的部分
   289      # print all of file EXCEPT section between 2 regular expressions
293 #删除复制,从一个文件连续行(模仿“ 唯一性”)。
   293      # delete duplicate, consecutive lines from a file (emulates "uniq").
299 #删除复制,从一个文件中不连续的线。注意不要
   299      # delete duplicate, nonconsecutive lines from a file. Beware not to
301 #溢出保留空间的缓冲器的大小,否则使用GNU sed。
   301      # overflow the buffer size of the hold space, or else use GNU sed.
305 #删除重复行的所有行(模仿“ uniq -d”)。
   305      # delete all lines except duplicate lines (emulates "uniq -d").
309 #删除一个F的前10行
   309      # delete the first 10 lines of a file



您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP