bc-bd.org

Not a blog

Matching ] With Sed

Trying to match ] with sed needs some precautions:

$ echo "[foo   U ] abc/def [bar]" | sed 's/\([^]]\)\+] \([^ ]*\).*/\2/'
abc/def

Or use awk:

$ echo "[foo   U ] abc/def [bar]" | awk -F '[][]' '{print $3}'
 abc/def