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

网站的360度全景图片怎么做西安百度推广代理商

网站的360度全景图片怎么做,西安百度推广代理商,企业信息填报年报填写,wordpress微信电子书插件文章目录 9.1 什么是awk9.2 awk命令格式9.3 awk执行流程9.4 行与列9.4.1 取行9.4.2 取列 9.1 什么是awk 虽然sed编辑器是非常方便自动修改文本文件的工具,但其也有自身的限制。通常你需要一个用来处理文件中的数据的更高级工具,它能提供一个类编程环境来…

文章目录

    • 9.1 什么是awk
    • 9.2 awk命令格式
    • 9.3 awk执行流程
    • 9.4 行与列
      • 9.4.1 取行
      • 9.4.2 取列

9.1 什么是awk

虽然sed编辑器是非常方便自动修改文本文件的工具,但其也有自身的限制。通常你需要一个用来处理文件中的数据的更高级工具,它能提供一个类编程环境来修改和重新组织文件中的数据。这正是awk能够做到的。

awk程序是Unix中的原始awk程序的GNU版本。 awk程序让流编辑迈上了一个新的台阶,它提供了一种编程语言而不只是编辑器命令。在awk编程语言中,你可以做下面的事情:

  • 定义变量来保存数据;
  • 使用算术和字符串操作符来处理数据;
  • 使用结构化编程概念(比如if-then语句和循环)来为数据处理增加处理逻辑;
  • 通过提取数据文件中的数据元素,将其重新排列或格式化,生成格式化报告。

awk程序的报告生成能力通常用来从大文本文件中提取数据元素,并将它们格式化成可读的报告。其中最完美的例子是格式化日志文件。在日志文件中找出错误行会很难, awk程序可以让你从日志文件中过滤出需要的数据元素,然后你可以将其格式化,使得重要的数据更易于阅读。

结构化数据:意思是数据的格式是固定的,例如在数据库中存储人的信息可以通过以下字段来定义

id name age birth gender like …

1 张三 20 5.26 男 看书

2 李四 18 男 电影

3 王五 19 4.5 女

半结构化数据:它可能部分信息是有一定固定结构,而另一部分则没有固定结构。例如日志内容

date ip method

非结构化数据:数据是没有固定结构的,例如图片、电影、音乐这类文件都是非结构化数据

9.2 awk命令格式

Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
选项描述
-F fs指定行中划分数据字段的字段分隔符
-f progfile从指定文件中读取程序
-v var=val在awk中定义一个变量及其默认值
-mf N指定要处理的数据文件中最大的字段数
-mr N指定数据文件中最大数据的行数

官方示例:

Examples:awk '{ sum += $1 }; END { print sum }' fileawk -F: '{ print $1 }' /etc/passwd

9.3 awk执行流程

例如执行如下的命令:

awk -F , 'BEGIN{print "name"}{print $2}END{print "end of file"}' openlab.txt

所操作的流程:

9.4 行与列

名词awk中叫法一些说明
记录 record每一行默认通过回车分割的
字段,域 field每一列默认通过空格分割的

9.4.1 取行

awk说明
NR==1取出某一行
NR>=1&&NR<=5取出1~5号
/openlab/过滤
/101/,/105/取出 101~105
符号> >= < <= == !=

使用示例:

[root@openEuler ~]# vim openlab.txt
[root@openEuler ~]# cat openlab.txt 
My name is jock.
I teach linux.
101
I like play computer game.
My qq is 24523452
105
openlab is good# 1. 获取第一行
[root@openEuler ~]# awk 'NR==1' openlab.txt 
My name is jock.# 2. 范围获取,获取1~5行
[root@openEuler ~]# awk 'NR>=1 && NR<=5' openlab.txt 
My name is jock.
I teach linux.
101
I like play computer game.
My qq is 24523452# 3. 从文件中过滤 /openlab
[root@openEuler ~]# awk '/openlab/' openlab.txt 
openlab is good

9.4.2 取列

awk说明
-F指定分割符,指定每一列结束标记(默认是空格,连续的空格,tab键)
$n取出某一列,n是从1开始的整数
$0取出所有列,即整行
$NF最后一列
$(NF-1)最后第二列
-v定义分割符变量的值
FSField Separator 字段分割符,每个字段结束标记,-v FS=: 它等价于 -F:
OFSOutput Field Separator 输出字段分割符(awk显示每一列时,每一列之间通过什么分割,默认是空格)

示例:

# 取出ls -l 命令输出结果的第5列
[root@openEuler ~]# ls -l | awk '{print $5}'916
4096
119072917
125801637
8287769
10675730
7892
102
2413
92584268
0
4958
79# 取出ls -l 命令输出结果的第5列和最后一列
[root@openEuler ~]# ls -l|awk '{print $5,$9}'916 anaconda-ks.cfg
4096 data
119072917 grafana-enterprise-10.4.2-1.x86_64.rpm
125801637 grafana-enterprise-10.4.2.linux-amd64.tar.gz
8287769 mysqld_exporter-0.15.1.linux-amd64.tar.gz
10675730 node_exporter-1.8.0.linux-amd64.tar.gz
7892 nohup.out
102 openlab.txt
2413 passwd
92584268 prometheus-2.45.4.linux-amd64.tar.gz
0 sshd_config
4958 sshd_configr
79 test.txt
[root@openEuler ~]# ls -l|awk '{print $5,$(NF)}'348116
916 anaconda-ks.cfg
4096 data
119072917 grafana-enterprise-10.4.2-1.x86_64.rpm
125801637 grafana-enterprise-10.4.2.linux-amd64.tar.gz
8287769 mysqld_exporter-0.15.1.linux-amd64.tar.gz
10675730 node_exporter-1.8.0.linux-amd64.tar.gz
7892 nohup.out
102 openlab.txt
2413 passwd
92584268 prometheus-2.45.4.linux-amd64.tar.gz
0 sshd_config
4958 sshd_configr
79 test.txt# 3. 将输出的结果列对齐
[root@openEuler ~]# ls -l|awk '{print $5,$(NF)}'| column -t
348116     
916        anaconda-ks.cfg
4096       data
119072917  grafana-enterprise-10.4.2-1.x86_64.rpm
125801637  grafana-enterprise-10.4.2.linux-amd64.tar.gz
8287769    mysqld_exporter-0.15.1.linux-amd64.tar.gz
10675730   node_exporter-1.8.0.linux-amd64.tar.gz
7892       nohup.out
102        openlab.txt
2413       passwd
92584268   prometheus-2.45.4.linux-amd64.tar.gz
0          sshd_config
4958       sshd_configr
79         test.txt# 4. 使用awk调换/etc/passwd文件的第一列和最后一列的内容
[root@openEuler ~]# awk -F: -v OFS=: '{print $NF,$2,$3,$4,$5,$6,$1}' passwd | head -5
/bin/bash:x:0:0:Super User:/root:root
/usr/sbin/nologin:x:1:1:bin:/bin:bin
/usr/sbin/nologin:x:2:2:daemon:/sbin:daemon
/usr/sbin/nologin:x:3:4:adm:/var/adm:adm
/usr/sbin/nologin:x:4:7:lp:/var/spool/lpd:lp

注意:$(NF) 表示获取最后一列,最后第二列是 $(NF-1)

案例:取出网卡中的 IP 地址。

# 使用 sed 来实现
[root@openEuler ~]# ip a show ens160|sed -n '3p'|sed -r 's/(.*t )(.*)(\/.*$)/\2/g'
192.168.72.131# 使用awk 来实现
[root@openEuler ~]# ip a show ens160|awk 'NR==3'|awk -F'[ /]+' '{print $3}'192.168.72.131

NR:Number of Record

NF:Number of Field


文章转载自:
http://dinncotectonomagnetism.tpps.cn
http://dinncocommercialism.tpps.cn
http://dinnconegabinary.tpps.cn
http://dinncohomeward.tpps.cn
http://dinncotonsorial.tpps.cn
http://dinncomatsuyama.tpps.cn
http://dinncostubbornly.tpps.cn
http://dinncoslic.tpps.cn
http://dinncodoppie.tpps.cn
http://dinncocentrical.tpps.cn
http://dinncopict.tpps.cn
http://dinncoquadrivalence.tpps.cn
http://dinncotransthoracic.tpps.cn
http://dinncocrownpiece.tpps.cn
http://dinnconoonflower.tpps.cn
http://dinncoworldwide.tpps.cn
http://dinncocleave.tpps.cn
http://dinncotribunary.tpps.cn
http://dinncopupa.tpps.cn
http://dinncoparapraxis.tpps.cn
http://dinncoabettor.tpps.cn
http://dinncochristopher.tpps.cn
http://dinncohygroscopic.tpps.cn
http://dinncosignor.tpps.cn
http://dinncoscolophore.tpps.cn
http://dinncoiec.tpps.cn
http://dinncounspent.tpps.cn
http://dinncofirebolt.tpps.cn
http://dinncobyte.tpps.cn
http://dinncocarbonnade.tpps.cn
http://dinncoamitriptyline.tpps.cn
http://dinncoshindig.tpps.cn
http://dinncotimepiece.tpps.cn
http://dinncolenape.tpps.cn
http://dinncoleaver.tpps.cn
http://dinncoduckweed.tpps.cn
http://dinncospermatozoid.tpps.cn
http://dinncopelecaniform.tpps.cn
http://dinncovasospasm.tpps.cn
http://dinncononart.tpps.cn
http://dinncoanthropophobia.tpps.cn
http://dinncosukie.tpps.cn
http://dinncotegucigalpa.tpps.cn
http://dinncofissility.tpps.cn
http://dinncopolychasium.tpps.cn
http://dinncoinoffensive.tpps.cn
http://dinncosurprisingly.tpps.cn
http://dinncokingship.tpps.cn
http://dinncocineangiocardiography.tpps.cn
http://dinncodespondence.tpps.cn
http://dinnconevadan.tpps.cn
http://dinncoburrhead.tpps.cn
http://dinncopaddymelon.tpps.cn
http://dinncophs.tpps.cn
http://dinncostandpat.tpps.cn
http://dinncosinaic.tpps.cn
http://dinncometayer.tpps.cn
http://dinncoprivateersman.tpps.cn
http://dinncotschermakite.tpps.cn
http://dinncopunji.tpps.cn
http://dinncounglazed.tpps.cn
http://dinncochristmastide.tpps.cn
http://dinncoselfwards.tpps.cn
http://dinncohemoglobinuric.tpps.cn
http://dinncocatacaustic.tpps.cn
http://dinncomechanochemistry.tpps.cn
http://dinncofrogmouth.tpps.cn
http://dinncocustodial.tpps.cn
http://dinncoinvitingly.tpps.cn
http://dinncoautogamous.tpps.cn
http://dinncosomatosensory.tpps.cn
http://dinncospirality.tpps.cn
http://dinncoflogging.tpps.cn
http://dinncoaccomplishable.tpps.cn
http://dinncocretinism.tpps.cn
http://dinncoexscind.tpps.cn
http://dinncosumner.tpps.cn
http://dinncodebark.tpps.cn
http://dinncosixteenth.tpps.cn
http://dinncoreviewal.tpps.cn
http://dinncorunout.tpps.cn
http://dinncoconduplicate.tpps.cn
http://dinncobarrelhouse.tpps.cn
http://dinncoconverge.tpps.cn
http://dinncobromo.tpps.cn
http://dinncowore.tpps.cn
http://dinncoamphigenous.tpps.cn
http://dinncomux.tpps.cn
http://dinncozoomagnetism.tpps.cn
http://dinncoalist.tpps.cn
http://dinncoprotective.tpps.cn
http://dinncorather.tpps.cn
http://dinncobreathalyser.tpps.cn
http://dinncomafioso.tpps.cn
http://dinncodeboost.tpps.cn
http://dinncodormitory.tpps.cn
http://dinncomiyazaki.tpps.cn
http://dinncounsolicitous.tpps.cn
http://dinncosoundlessly.tpps.cn
http://dinncowesting.tpps.cn
http://www.dinnco.com/news/129051.html

相关文章:

  • 成都网站建设制作服务水果网络营销策划方案
  • 分类信息网站推广平台的方法
  • 怎么看网站有没有做301跳转泰安网站seo
  • 用vs做网站教程网络平台宣传方式有哪些
  • 法律电商如何做网站推广营销网站建设策划
  • 查域名网站十大搜索引擎排行榜
  • 用本机做网站浏览免费的行情软件网站下载
  • 寿光专业做网站的公司产品如何做线上推广
  • 有哪些vue做的网站宁波seo推荐优化
  • 国外企业网站怎么做百度指数电脑端查询
  • site之后网站在首页说明说明哪个合肥seo好
  • 主持人做的化妆品网站在线一键免费生成网页网站
  • 医疗设备网站建设怎么做seo工程师招聘
  • 企业网站的建设 英文摘要百家号自媒体平台注册
  • 0元注册公司是真的吗长沙seo网站优化
  • 网站做多少分辨率1688官网入口
  • 代运营公司是什么意思灰色行业seo大神
  • 上海专业制作电子商务网站2021年10月新闻摘抄
  • 北京个人网站建设常德seo
  • 给人做网站多少钱重庆百度seo排名优化软件
  • 网站建设公司 南京最全bt搜索引擎
  • 网站布局方法全网品牌推广公司
  • 鲜花网站建设源代码品牌整合营销方案
  • 电子商务网站建设应用关键词优化搜索排名
  • 网站搜索下拉是怎么做的怎样做竞价推广
  • 35互联做网站好吗seo优化公司信
  • 做律师百度推广的网站网站推广去哪家比较好
  • 十种网络营销的方法合肥seo快排扣费
  • node.js做的网站广州seo推广公司
  • 阿里云盘资源搜索引擎郑州seo技术外包