My goal is to display only the text after last ] symbol.
echo MY_TEXT | grep -o "[^\]]*$"
The output is just the last symbol.
If I change “]” symbol to any letter, it works as expected.
Examples:
$ echo Hello World | grep -o '[^o]*$'
rld # and this is correct!
$ echo He]ll]o Wo]rld | grep -o "[^\]]*$"
d # but expected: rld
Why behavior is different for symbol o and ]?
Thank you in advance.
You do not need to escape the
]:Produces:
rld