2 added 397 characters in body
source | link

There are two problems with your first attempt. {.*} contains special characters which need to be protected from expansion by the shell; put quotes around the pattern. Also, {.*} matches the longest brace-delimited text on the line, so if you have a line containing hello {test1} world {test2} howdy then the output is {test1} world {test2} becaause .* matched test1} world {test2.

The following will output only what is between brackets.

grep -o -e "{[^}]*}" 

My original formulation used "{.*}", but with that the widest bracket found within a line, not the smallest one would be returned...

The following will output only what is between brackets.

grep -o -e "{[^}]*}" 

My original formulation used "{.*}", but with that the widest bracket found within a line, not the smallest one would be returned...

There are two problems with your first attempt. {.*} contains special characters which need to be protected from expansion by the shell; put quotes around the pattern. Also, {.*} matches the longest brace-delimited text on the line, so if you have a line containing hello {test1} world {test2} howdy then the output is {test1} world {test2} becaause .* matched test1} world {test2.

The following will output only what is between brackets.

grep -o -e "{[^}]*}" 

My original formulation used "{.*}", but with that the widest bracket found within a line, not the smallest one would be returned...

1
source | link

The following will output only what is between brackets.

grep -o -e "{[^}]*}" 

My original formulation used "{.*}", but with that the widest bracket found within a line, not the smallest one would be returned...