regex - Sed to replace this pattern with null -


a string format

aaa,bbb,ccc,ddd,pattern:[[xxxxxxxxxxxx],[yyyyyyyyyyyyyyy]],eee,fff,pattern:[[eeeeeeeeee],[fffffffff]] 

how can use sed replace pattern:[[ ???????????? ]] null

example

sed s/pattern:[[ ????????? ]]//g

i tried sed s/pattern:\[\[\([^]]*\)\]\]//g not work.

you can use perl sed doesn't support non-greedy matching:

s='aaa,bbb,ccc,ddd,pattern:[[xxxxxxxxxxxx],[yyyyyyyyyyyyyyy]],eee,fff,pattern:[[eeeeeeeeee],[fffffffff]]'  perl -pe 's/pattern:\[\[.*?\]\]//g' <<< "$s"  aaa,bbb,ccc,ddd,,eee,fff, 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -