我正在尝试提取在
"profile "
和"]"
之间的单词。
我的内容
[profile gateway]
[profile personal]
[profile DA]
[profile CX]
为此我已经尝试过
less ~/.aws/config |grep "\[profile"|sed -E 's/\[profile(.)//'
这提供了
gateway]
personal]
DA]
CX]
我知道可以用管道和tr
来删除最后一个 "]"
,或者使用cut
命令。但是有没有人能帮我使用正则表达式修改上述的sed
命令,以删除最后一个"]"
字符呢?
sed -E 's/\[//;s/\]//;s/profile //'
。 - Cristian Ramon-Cortes