how to use sed, awk, or gawk to print only what is matched?

后端 未结 11 492
长情又很酷
长情又很酷 2021-01-30 05:59

I see lots of examples and man pages on how to do things like search-and-replace using sed, awk, or gawk.

But in my case, I have a regular expression that I want to run

11条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 06:37

    For awk. I would use the following script:

    /.*abc([0-9]+)xyz.*/ {
                print $0;
                next;
                }
                {
                /* default, do nothing */
                }
    

提交回复
热议问题