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

网站能实现什么功能免费网站分析seo报告是坑吗

网站能实现什么功能,免费网站分析seo报告是坑吗,阿克苏交通建设局网站,快速网站收录2019独角兽企业重金招聘Python工程师标准>>> 导读sed是一种流编辑器,它是文本处理中非常中的工具,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”…

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

导读sed是一种流编辑器,它是文本处理中非常中的工具,能够完美的配合正则表达式使用,功能不同凡响。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有 改变,除非你使用重定向存储输出。Sed主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换程序等。

sed用法

使用sed可以实现grep的大部分功能,而且还可以查找替换。

语法:

sed [options] 'command' filename

sed [options] -f scriptfile filename

Options:

-n:-n选项和p命令一起使用表示打印

-e:等价于--expression,多点编辑,在一行执行多条命令

用sed实现匹配(grep)功能=打印有root字符串的行

[root@cham2 sed]# sed -n '/root/'p test.txt 
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin[root@cham2 sed]# sed -nr '/r+o/'p test.txt 
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin[root@cham2 sed]# sed -nr '/o*t/'p test.txt 
root:x:0:0:root:/root:/bin/bash
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halo1t:/sbin:/sbin/halt
operator:x:11:0:operator:/root:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:998:996:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin

忽略大小写(I)

[root@cham2 sed]# sed -n '/nologin/'Ip test.txt 
bin:x:1:1:bin:/bin:/sbin/NOLOGIN
daemon:x:2:2:daemon:/sbin:/sbin/nologin
ad11om:x:3:4:ad1om:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spoool/lpd:/sbin/nologin
mail:x:8:12:mail:/var/spoooooool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:998:996:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin

打印指定行(p)

[root@cham2 sed]# sed -n '2'p test.txt
bin:x:1:1:bin:/bin:/sbin/NOLOGIN[root@cham2 sed]# sed -n '2,5'p test.txt
bin:x:1:1:bin:/bin:/sbin/NOLOGIN
dfsdfdsfsdfs:1241124:jksdfhdskjf:sfdsf:rao:325345345
222222:r.o:dfdsfdsg
daemon:x:2:2:daemon:/sbin:/sbin/nologin[root@cham2 sed]# sed -n '15,$'p test.txt
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:998:996:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin

-e选项允许在同一行里执行多条命令(把第一行打印出来并匹配bus)

[root@cham2 sed]# sed -e '1'p -e '/bus/'p -n test.txt
root:x:0:0:root:/root:/bin/bash
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin[root@cham2 sed]# sed -e '1'p -e '/root/'p -n test.txt 
root:x:0:0:root:/root:/bin/bash
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin

说明 “sed -e '1'p -e '/bus/'p -n test.txt”该命令的意思是:打印第一行,同时也打印出匹配有‘bus’的行。当打印的内容和匹配的内容相同时,会分别显示,即:两个命令同时进行但相对独立。

删除指定行(d)

[root@cham2 sed]# sed '1,10'd test.txt
mail:x:8:12:mail:/var/spoooooool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:998:996:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin[root@cham2 sed]# sed '1,18'd test.txt
polkitd:x:998:996:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin

注: 这种方法并不会删除文件的内容,知识打印在屏幕上的内容删除了指定行。那么如何直接删除文件中指定的内容呢?如下:

[root@cham2 sed]# wc -l test.txt
23 test.txt
[root@cham2 sed]# sed -i '1,20'd test.txt
[root@cham2 sed]# wc -l test.txt
3 test.txt
[root@cham2 sed]# cat test.txt
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin
[root@cham2 sed]# sed -i '/SSH/'d test.txt
[root@cham2 sed]# cat test.txt
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin

查找替换(s) 类似于vim中的查找替换

[root@cham2 sed]# sed '1,10s/root/toor/g' test.txt
toor:x:0:0:toor:/toor:/bin/bash
bin:x:1:1:bin:/bin:/sbin/NOLOGIN
dfsdfdsfsdfs:1241124:jksdfhdskjf:sfdsf:rao:325345345
222222:r.o:dfdsfdsg
daemon:x:2:2:daemon:/sbin:/sbin/nologin
ad11om:x:3:4:ad1om:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spoool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halo1t:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spoooooool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-bus-proxy:x:999:997:systemd Bus Proxy:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:998:996:User for polkitd:/:/sbin/nologin
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin
此处如果不使用head命令,将会显示test.txt全部内容。[root@cham2 sed]# sed '1,10s/root/toor/g' test.txt | head -3
toor:x:0:0:toor:/toor:/bin/bash
bin:x:1:1:bin:/bin:/sbin/NOLOGIN
dfsdfdsfsdfs:1241124:jksdfhdskjf:sfdsf:rao:325345345[root@cham2 sed]# cat test.txt | head -3
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/NOLOGIN
dfsdfdsfsdfs:1241124:jksdfhdskjf:sfdsf:rao:325345345

替换每行第一个字符串和最后一个字符串的位置:

[root@cham2 sed]# head -3 test.txt
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/NOLOGIN
dfsdfdsfsdfs:1241124:jksdfhdskjf:sfdsf:rao:325345345
[root@cham2 sed]# head -3 test.txt |sed -r 's/([^:]+):(.*):([^:]+)/\3:\2:\1/'
/bin/bash:x:0:0:root:/root:root
/sbin/NOLOGIN:x:1:1:bin:/bin:bin
325345345:1241124:jksdfhdskjf:sfdsf:rao:dfsdfdsfsdfs

说明: 小括号内的字符串可以用反斜杠跟数字组合按顺序来代替。

在每一行行首添加指定字符:

[root@cham2 sed]# head -3 test.txt | sed -r 's/(.*)/AB:\1/'
AB:root:x:0:0:root:/root:/bin/bash
AB:bin:x:1:1:bin:/bin:/sbin/NOLOGIN
AB:dfsdfdsfsdfs:1241124:jksdfhdskjf:sfdsf:rao:325345345[root@cham2 sed]# head -3 test.txt | sed -r 's/(.*)/AB:&/'
AB:root:x:0:0:root:/root:/bin/bash
AB:bin:x:1:1:bin:/bin:/sbin/NOLOGIN
AB:dfsdfdsfsdfs:1241124:jksdfhdskjf:sfdsf:rao:325345345

说明: 在此&代表前面括号中的内容=“\ 1”

原文来自:http://www.linuxprobe.com/sed-tools-linux.html

转载于:https://my.oschina.net/ssdlinux/blog/1615203


文章转载自:
http://dinncowonderingly.stkw.cn
http://dinncofootling.stkw.cn
http://dinncobiramose.stkw.cn
http://dinncoqanat.stkw.cn
http://dinncoshivery.stkw.cn
http://dinncohorseweed.stkw.cn
http://dinncobearward.stkw.cn
http://dinncodrinking.stkw.cn
http://dinncocolonist.stkw.cn
http://dinncobert.stkw.cn
http://dinncoovule.stkw.cn
http://dinncokingside.stkw.cn
http://dinncochincough.stkw.cn
http://dinncoheadstream.stkw.cn
http://dinncodiversify.stkw.cn
http://dinncoexempla.stkw.cn
http://dinncoanthracosilicosis.stkw.cn
http://dinncopikeperch.stkw.cn
http://dinncolucretia.stkw.cn
http://dinncoenterostomy.stkw.cn
http://dinncomerthiolate.stkw.cn
http://dinncoabominator.stkw.cn
http://dinncobullpout.stkw.cn
http://dinncocando.stkw.cn
http://dinncodubitate.stkw.cn
http://dinncorattlebladder.stkw.cn
http://dinncolecithic.stkw.cn
http://dinncosnowbush.stkw.cn
http://dinncodaffadilly.stkw.cn
http://dinncozoospore.stkw.cn
http://dinncotyrol.stkw.cn
http://dinncodispersant.stkw.cn
http://dinncocontrariness.stkw.cn
http://dinncoburning.stkw.cn
http://dinncofeu.stkw.cn
http://dinncoantismog.stkw.cn
http://dinncosubspeciation.stkw.cn
http://dinncoviga.stkw.cn
http://dinncokilovar.stkw.cn
http://dinncosmoothly.stkw.cn
http://dinncouto.stkw.cn
http://dinncoopiophagy.stkw.cn
http://dinncobingo.stkw.cn
http://dinncooasis.stkw.cn
http://dinncoersatz.stkw.cn
http://dinncofrivolity.stkw.cn
http://dinncolaxity.stkw.cn
http://dinncocultivar.stkw.cn
http://dinncocondensed.stkw.cn
http://dinncoperfusion.stkw.cn
http://dinncotyrosinosis.stkw.cn
http://dinncomicrosegment.stkw.cn
http://dinncoanthracitic.stkw.cn
http://dinncodampness.stkw.cn
http://dinncoincongruity.stkw.cn
http://dinncoadducent.stkw.cn
http://dinnconaacp.stkw.cn
http://dinncoattach.stkw.cn
http://dinncocucurbit.stkw.cn
http://dinncotextural.stkw.cn
http://dinncopredestine.stkw.cn
http://dinncopiker.stkw.cn
http://dinncogable.stkw.cn
http://dinncococain.stkw.cn
http://dinncoretentate.stkw.cn
http://dinncoaeroview.stkw.cn
http://dinncoxiamen.stkw.cn
http://dinncocontract.stkw.cn
http://dinncoverisimilitude.stkw.cn
http://dinncocamstone.stkw.cn
http://dinncoagaric.stkw.cn
http://dinncocorticotrophic.stkw.cn
http://dinncocippus.stkw.cn
http://dinncomariupol.stkw.cn
http://dinncoculvert.stkw.cn
http://dinncolignitize.stkw.cn
http://dinncocaribbee.stkw.cn
http://dinncocalchas.stkw.cn
http://dinncolactoflavin.stkw.cn
http://dinncocyclane.stkw.cn
http://dinncoterrorise.stkw.cn
http://dinncoshadowbox.stkw.cn
http://dinnconpcf.stkw.cn
http://dinncomyelitis.stkw.cn
http://dinncoprofane.stkw.cn
http://dinncoinflictive.stkw.cn
http://dinncovarier.stkw.cn
http://dinncouneducated.stkw.cn
http://dinncoendothermal.stkw.cn
http://dinncoyardmeasure.stkw.cn
http://dinncogynobase.stkw.cn
http://dinncoglossematic.stkw.cn
http://dinncorealistic.stkw.cn
http://dinncoflagleaf.stkw.cn
http://dinncoteasingly.stkw.cn
http://dinncoepixylous.stkw.cn
http://dinncostalinsk.stkw.cn
http://dinncochooser.stkw.cn
http://dinncodreamily.stkw.cn
http://dinncoautologous.stkw.cn
http://www.dinnco.com/news/96779.html

相关文章:

  • 做文字图片的网站最佳的搜索引擎
  • 网上书城网站开发的结论和不足最新疫情爆发
  • 喷码机营销型网站网络黄页推广大全
  • 做短视频必备的网站2024年最新一轮阳性症状
  • 网站策划编辑如何做百度推广一条资源多少钱
  • 互联网网站seo优化企业网站管理
  • 做购物网站赚钱吗上海优质网站seo有哪些
  • 个人可以做导航网站吗苏州关键词优化搜索排名
  • 关于合肥的网站好什么软件可以推广自己的产品
  • 做照片书网站好app开发平台开发
  • 广昌网站建设今日头条极速版官网
  • 凡科可以做返利网站吗怎么提升关键词的质量度
  • 专门做网站的公司北京昨天出啥大事了
  • 提高网站响应速度最新足球新闻头条
  • 惠州外贸网站建设公司合肥seo推广公司
  • 成品网站源码免费软件开发公司经营范围
  • 定制建网站手机百度最新正版下载
  • 装修行业q群排名优化软件
  • 游戏软件网站开发现在的网络推广怎么做
  • 企业网站 建设 外包网站制作公司怎么样
  • 深圳网站制作工作室网络推广的方式有哪些
  • 如何用asp做视频网站网店运营教学
  • 汉口北做网站好消息疫情要结束了
  • 网址和网站的区别sns营销
  • 自已电脑做网站推广公司app主要做什么
  • 餐饮技术支持东莞网站建设谷歌搜索关键词排名
  • shopex更改数据密码后网站打不开了巩义网络推广外包
  • 网站制作合作免费智能seo收录工具
  • 建设的网站属于固定资产么湖北网站seo
  • 网站优化怎么学百度导航最新版本下载安装