gpt4 book ai didi

linux - 从左侧和右侧删除文本并将字符串保留在中间

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:07:18 26 4
gpt4 key购买 nike

有没有办法在linux中修改这个字符串

<host endtime="1495011823"><address addr="185.127.7.58" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="115"/></port></ports></host>
<host endtime="1495011823"><address addr="188.128.124.114" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="46"/></port></ports></host>
<host endtime="1495011823"><address addr="163.191.210.41" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="236"/></port></ports></host>
<host endtime="1495011823"><address addr="97.78.205.11" addrtype="ipv4"/><ports><port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="45"/></port></ports></host>
<host endtime="1495011823"><address addr="93.103.218.96" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="112"/></port></ports></host>
<host endtime="1495011823"><address addr="75.106.77.247" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="237"/></port></ports></host>
<host endtime="1495011823"><address addr="5.200.35.35" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="120"/></port></ports></host>
<host endtime="1495011823"><address addr="147.196.146.236" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="55"/></port></ports></host>
<host endtime="1495011823"><address addr="89.21.189.7" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="53"/></port></ports></host>
<host endtime="1495011823"><address addr="78.139.51.5" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="108"/></port></ports></host>
<host endtime="1495011823"><address addr="62.193.141.140" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="107"/></port></ports></host>
<host endtime="1495011823"><address addr="136.227.47.165" addrtype="ipv4"/><ports><port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="217"/></port></ports></host>
<host endtime="1495011823"><address addr="109.177.46.82" addrtype="ipv4"/><ports><port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="50"/></port></ports></host>
<host endtime="1495011823"><address addr="89.116.124.135" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="110"/></port></ports></host>
<host endtime="1495011823"><address addr="88.245.53.232" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="112"/></port></ports></host>
<host endtime="1495011823"><address addr="101.55.37.147" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="108"/></port></ports></host>
<host endtime="1495011823"><address addr="206.201.204.229" addrtype="ipv4"/><ports><port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="218"/></port></ports></host>
<host endtime="1495011823"><address addr="120.24.86.220" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="102"/></port></ports></host>
<host endtime="1495011823"><address addr="120.42.185.100" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="43"/></port></ports></host>
<host endtime="1495011823"><address addr="115.47.49.146" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="102"/></port></ports></host>

我需要从左边删除这个:

<host endtime="1495011823"><address addr="

这部分从右边开始:

" addrtype="ipv4"/><ports><port protocol="tcp" portid="3389"><state state="open" reason="syn-ack" reason_ttl="115"/></port></ports></host>

image

只保留中间的ip我怎样才能在 linux 中使用 sed 命令做到这一点??

最佳答案

sed 's/^.*addr="\([^"]*\).*$/\1/' file

echo $line |sed 's/^.*addr="\([^"]*\).*$/\1/'

关于linux - 从左侧和右侧删除文本并将字符串保留在中间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44083569/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com