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

后端 未结 11 482
长情又很酷
长情又很酷 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:38

    you can do it with the shell

    while read -r line
    do
        case "$line" in
            *abc*[0-9]*xyz* ) 
                t="${line##abc}"
                echo "num is ${t%%xyz}";;
        esac
    done <"file"
    

提交回复
热议问题