extract a string after a pattern

后端 未结 4 983
失恋的感觉
失恋的感觉 2021-02-09 11:33

I want to extract the numbers following client_id and id and pair up client_id and id in each line.

For example, for the following lines of log,

User(cli         


        
4条回答
  •  别跟我提以往
    2021-02-09 12:31

    This may work for you:

    awk -F "[):,]" '{ for (i=2; i<=NF; i++) if ($i ~ /id/) print $2, $(i+1) }' file
    

    Results:

    03 204
    03 491
    03 29
    04 209
    04 301
    05 20
    

提交回复
热议问题