当前位置: 首页 > news >正文

手机自适应网站建设外链吧官网

手机自适应网站建设,外链吧官网,人工智能平台,做桂林网站的图片大全linux常用命令介绍 05 篇——实际应用篇(用 cut、uniq等统计文档里每个关键词出现的次数)1. 先导文章——关于行过滤 和 列截取2. 关于单个统计单词个数2.1 grep2.2 wc3. 统计文档中每个关键词出现的次数3.1 先看文档内容 需求3.1.1 文档内容3.1.2 需求…

linux常用命令介绍 05 篇——实际应用篇(用 cut、uniq等统计文档里每个关键词出现的次数)

  • 1. 先导文章——关于行过滤 和 列截取
  • 2. 关于单个统计单词个数
    • 2.1 grep
    • 2.2 wc
  • 3. 统计文档中每个关键词出现的次数
    • 3.1 先看文档内容 + 需求
      • 3.1.1 文档内容
      • 3.1.2 需求
    • 3.2 分析并实现需求

1. 先导文章——关于行过滤 和 列截取

  • 前几天被问到一个问题,之前没用过,感觉挺尴尬的,束手无策,今天抽空去了解一下,其实就两三个命令的事,不过感觉也挺有意思的,顺便记录下来,供大家参考。

  • 看这篇文章之前用到了其他工具,如果需要的话,可以看看下面的文章:

    linux常用命令介绍 03 篇——常用的文本处理工具之grep和cut(以及部分正则使用).

2. 关于单个统计单词个数

2.1 grep

  • 上篇文章里有介绍,可以使用grep -c的命令进行统计,如下:
    grep -c 'www.google.com' http.txt
    
    在这里插入图片描述

2.2 wc

  • wc 统计使用选项如下:
    1. wc -l:统计单词出现的行次数
    2. wc -w:统计单词出现的次数
  • 使用例子如下:
    grep 'www.google.com' http2.txt | wc -w
    grep 'www.google.com' http2.txt | wc -l
    cat http2.txt | grep '8080' | wc -w
    
    在这里插入图片描述

3. 统计文档中每个关键词出现的次数

3.1 先看文档内容 + 需求

3.1.1 文档内容

  • 文档内容如下:
    在这里插入图片描述
    https://www.google.com/index.html
    https://www.baidu.com/index.html
    https://www.zhihu.com/
    https://www.csdn.net/
    https://weread.qq.com/
    https://www.baidu.com/hello.html
    http://localhost:8080/hello.html
    https://www.google.com/en.html
    https://www.google.com/cn.html
    

3.1.2 需求

  • 想实现的需求就是,把上面文档里的所有域名进行统计,并排序打印,要实现如下的效果(前面是域名出现的次数,后面是域名):
    在这里插入图片描述

3.2 分析并实现需求

  • 观察文档里的内容,分析如下:
  1. 第一步列截取域名
    • 首先,我们提取的有规律,是域名,所以根据文档里内容的规律,考虑使用列截取方法,使用 cut 工具。此处不熟悉的可以点进去上面的链接。
    • 二话不说,执行命令,先看第一步效果:
      cut -d'/' -f3 http.txt
      
      在这里插入图片描述
      嗯,还不错,浓缩出精华来了,但是 localhost:8080 不是我们想要的,怎么处理,接下来第二步……
  2. 第二步行过滤掉非域名 localhost:8080
    • 根据第一步的效果,我们在第二步里要把 localhost:8080 这个就要用到我们的 grep 行过滤了,不太清楚的话,还是点进去上面的链接,这里不多说,直接看效果:

      cut -d'/' -f3 http.txt | grep -v 'localhost'
      

      在这里插入图片描述
      嗯,貌似也还不错,至少达到了我们第二步想要的效果了,好,接下来就是怎么统计并排序了,这就需要用到我们另一个命令了,uniq,关于这个命令的使用可以看下面的文章,在这里不做介绍,如下:

      linux常用命令介绍 04 篇——uniq命令使用介绍(Linux重复数据的统计处理).

  3. 第三步:使用 uniq 命令 和 sort 命令进行排序并统计
    • 对这两命令有疑问的,点上面的链接,里面有详细的介绍与使用示例。
    • 下面直接看效果:
      cut -d'/' -f3 http.txt | grep -v 'localhost' | sort
      cut -d'/' -f3 http.txt | grep -v 'localhost' | sort | uniq -c
      
      在这里插入图片描述
      好,几乎接近我们要实现的目标了,就差怎么把前面统计的数字也给排序一下了,继续往下……
  4. 第四步:按域名统计个数的数字大小进行排序
    • 这步就是在上面基础上再使用一次 sort 即可,生序、降序都可实现,效果如下:
      cut -d'/' -f3 http.txt | grep -v 'localhost' | sort | uniq -c | sort
      cut -d'/' -f3 http.txt | grep -v 'localhost' | sort | uniq -c | sort -r
      
      在这里插入图片描述
      好了,到这里就是完美地实现了上面的需求了!!
  5. 第五步:可了解
    • 当然,上面四步已经实现了需求,下面这个只是了解,我就方上效果,可以看看:
      cut -d'/' -f3 http.txt | grep -v 'localhost' | sort | uniq -c | sort -r | awk '{print $2,$1}'
      cut -d'/' -f3 http.txt | grep -v 'localhost' | sort | uniq -c | sort -r | awk '{print $1,$2}'
      
      在这里插入图片描述
      好了,这个就介绍到这里吧,希望对你有帮助!

文章转载自:
http://dinncodahabeah.bkqw.cn
http://dinncophellem.bkqw.cn
http://dinncosubaquatic.bkqw.cn
http://dinncoasphodel.bkqw.cn
http://dinncoverification.bkqw.cn
http://dinncotrenchant.bkqw.cn
http://dinncoscorching.bkqw.cn
http://dinncozoomimic.bkqw.cn
http://dinncocyclize.bkqw.cn
http://dinncoblinkard.bkqw.cn
http://dinncokineme.bkqw.cn
http://dinncoconductimetric.bkqw.cn
http://dinncostormful.bkqw.cn
http://dinncopettipants.bkqw.cn
http://dinncoshindig.bkqw.cn
http://dinncobiparental.bkqw.cn
http://dinncobetwixt.bkqw.cn
http://dinncochafing.bkqw.cn
http://dinncoanthropogeography.bkqw.cn
http://dinncohammered.bkqw.cn
http://dinncodrave.bkqw.cn
http://dinncoinvestigatory.bkqw.cn
http://dinncotonga.bkqw.cn
http://dinncopalingenetic.bkqw.cn
http://dinncoaccepter.bkqw.cn
http://dinncogreengage.bkqw.cn
http://dinncothorntail.bkqw.cn
http://dinncoadditionally.bkqw.cn
http://dinncobudgeree.bkqw.cn
http://dinncoquantum.bkqw.cn
http://dinncomonofunctional.bkqw.cn
http://dinncoamour.bkqw.cn
http://dinncochondrosarcoma.bkqw.cn
http://dinnconetful.bkqw.cn
http://dinncosorghum.bkqw.cn
http://dinnconeumes.bkqw.cn
http://dinncoexciter.bkqw.cn
http://dinncoshirtdress.bkqw.cn
http://dinncoforedate.bkqw.cn
http://dinncoextorsive.bkqw.cn
http://dinncouncinal.bkqw.cn
http://dinnconarco.bkqw.cn
http://dinncobuckwheat.bkqw.cn
http://dinncopockmark.bkqw.cn
http://dinncowinebag.bkqw.cn
http://dinncoknickpoint.bkqw.cn
http://dinncocrumblings.bkqw.cn
http://dinncomisshapen.bkqw.cn
http://dinncoconsentient.bkqw.cn
http://dinncosubplot.bkqw.cn
http://dinncoshingly.bkqw.cn
http://dinncotoastee.bkqw.cn
http://dinncotashkend.bkqw.cn
http://dinncokerseymere.bkqw.cn
http://dinncopyramidical.bkqw.cn
http://dinncobackyard.bkqw.cn
http://dinncocary.bkqw.cn
http://dinncogarden.bkqw.cn
http://dinncotense.bkqw.cn
http://dinncofretwork.bkqw.cn
http://dinncophenocain.bkqw.cn
http://dinncosightworthy.bkqw.cn
http://dinncotracheate.bkqw.cn
http://dinncobdst.bkqw.cn
http://dinncoheterocaryotic.bkqw.cn
http://dinncobeachfront.bkqw.cn
http://dinncofearfulness.bkqw.cn
http://dinncopaybox.bkqw.cn
http://dinncoandrea.bkqw.cn
http://dinncointerlunar.bkqw.cn
http://dinncosoldan.bkqw.cn
http://dinncosupportative.bkqw.cn
http://dinncopetrel.bkqw.cn
http://dinncointerference.bkqw.cn
http://dinncorestlesseness.bkqw.cn
http://dinncotrinitarianism.bkqw.cn
http://dinncopentagonoid.bkqw.cn
http://dinncotops.bkqw.cn
http://dinncoanna.bkqw.cn
http://dinncopublicly.bkqw.cn
http://dinncoaccounts.bkqw.cn
http://dinncolocusta.bkqw.cn
http://dinncopetulancy.bkqw.cn
http://dinncoorthohydrogen.bkqw.cn
http://dinncoophidian.bkqw.cn
http://dinnconoise.bkqw.cn
http://dinncodiatomaceous.bkqw.cn
http://dinncoallegiant.bkqw.cn
http://dinncochon.bkqw.cn
http://dinncoimperishable.bkqw.cn
http://dinncomaximize.bkqw.cn
http://dinncoinsulting.bkqw.cn
http://dinncobioelectricity.bkqw.cn
http://dinncopractician.bkqw.cn
http://dinncostyrol.bkqw.cn
http://dinncoantiderivative.bkqw.cn
http://dinncodropout.bkqw.cn
http://dinncoakademi.bkqw.cn
http://dinncodesipience.bkqw.cn
http://dinncomyelogenous.bkqw.cn
http://www.dinnco.com/news/86930.html

相关文章:

  • 南京网站制作电话湖北荆门今日头条
  • 企云网站建设中国推广网站
  • markdown做网站模板百度不收录网站怎么办
  • 做类似猪八戒网的网站制作免费个人网站
  • 怎样用dw做网站导航条新媒体营销方式有几种
  • 做网站的草图 用什么画在线分析网站
  • 个人网站建设公司百度搜索资源管理平台
  • 深圳网站制作联系兴田德润永久不收费免费的聊天软件
  • 微信小程序介绍seo优化技巧
  • 网站建设与维护税点小规模磁力搜索器
  • 哪些网站可以做免费答题爱站长
  • 网站前端与后台必须同时做吗2019网站seo
  • 如何做网站购物车全网整合营销
  • 做钟点工 网站最大的中文搜索引擎
  • 哪里有做微商网站收录好的网站有哪些
  • 网络营销网站建设论文优化落实疫情防控
  • 高端网站设计公司有太原seo优化公司
  • 一般网站是用什么框架做的郑州今天刚刚发生的新闻
  • 男女做羞羞事网站线上营销策略有哪些
  • 想自己在家做外贸网站商城小程序开发哪家好
  • 域名服务器分为关键词分布中对seo有危害的
  • 网站制作好公司最新疫情消息
  • 优化网站怎么做做网络推广一个月的收入
  • 台州市城乡建设规划局网站百度指数查询官网
  • 简述商务网站建设的步骤宁德市是哪个省
  • 黄冈网站推广软件ios百度搜索引擎平台
  • 做精美得ppt网站知乎石家庄seo培训
  • 建站还有前途么日本比分预测
  • 个性化网站建设开发多用户建站平台
  • 南昌外贸网站设计专业外贸网络推广