unix 如何用grep或awk选择句子?[已关闭]

ldioqlga  于 2023-02-19  发布在  Unix
关注(0)|答案(1)|浏览(116)
    • 已关闭**。此问题需要超过focused。当前不接受答案。
    • 想要改进此问题吗?**更新此问题,使其仅关注editing this post的一个问题。

昨天关门了。
Improve this question

Domain name:
    jewelleryfurkeeps.co.uk

Data validation:
    Nominet was able to match the registrant's name and address against a 3rd party data source on 30-Nov-2022

Registrar:
    Namecheap, Inc. [Tag = NAMECHEAP-INC]
    URL: https://www.namecheap.com

我想要的
域名:www.example.com从上面这个我只想要〉jewelleryfurkeeps.co.ukjewelleryfurkeeps.co.uk from above this I want only > jewelleryfurkeeps.co.uk

bq8i3lrv

bq8i3lrv1#

使用perl
$ perl -0nE 'say $1 if /Domain name.*?URL:\s+(\S+)/s' file
使用awk
$ awk '/^Domain name/{p=1;next} /^$/{exit} p{gsub(/ /, "");print}' file
使用grep
grep -A1 '^Domain name' file | tail -n1 | tr -d ' '
输出
jewelleryfurkeeps.co.uk

相关问题