Extract string from brackets

后端 未结 9 1711
广开言路
广开言路 2020-12-23 16:26

I\'m pretty new at bash so this is a pretty noob question..

Suppose I have a string:

string1 [string2] string3 string4

I would like

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-23 16:34

    Here is an awk example, but I'm matching on parenthesis which also makes it more obvious of how the -F works.

    echo 'test (lskdjf)' | awk -F'[()]' '{print $2}'

提交回复
热议问题