How do I use grep to extract a specific field value from lines

后端 未结 2 774
情书的邮戳
情书的邮戳 2020-12-20 23:19

I have lines in a file which look like the following

....... DisplayName=\"john\" ..........

where .... represents variable nu

2条回答
  •  时光取名叫无心
    2020-12-20 23:53

    This works for me:

    awk -F "=" '/DisplayName/ {print $2}'
    

    which returns "john". To remove the quotes for john use:

    awk -F "=" '/DisplayName/ {gsub("\"","");print $2}'
    

提交回复
热议问题