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
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