You can very simply use awk with the field-separator of "{" and the substr and length($2) - 1 to trim the closing "}".
For example with your data:
$ awk -F"{" '/^[ ]*"data"/{print substr($2, 1, length($2)-1)}' json
stuff that i need
more stuff that i need
(note: you can trim the leading space before "stuff" in the 1st line if needed)
Quick Explanation
awk -F"{" invoke awk with a field-separator of '{',
/^[ ]*"data"/ locate only lines beginning with zero-or-more spaces followed by "data",
print substr($2, 1, length($2)-1) print the substring of the 2nd field from the first character to the length-1 character removing the closing '}'.
bash Solution
With bash you can loop over each line looking for a line beginning with "data" and then use a couple of simple parameter expansions to remove the unwanted parts of the line from each end. For instance:
$ while read -r line; do
[[ $line =~ ^\ *\"data\" ]] && {
line="${line#*\{}"
line="${line%\}*}"
echo $line
}
done <json
(With your data in the json filename, you can just copy/paste into a terminal)
Example Use/Output
$ while read -r line; do
> [[ $line =~ ^\ *\"data\" ]] && {
> line="${line#*\{}"
> line="${line%\}*}"
> echo $line
> }
> done <json
stuff that i need
more stuff that i need
(note: bash default word splitting even handles the leading whitespace for you)
While you can do it with awk and bash, any serious JSON manipulation should be done with the jq utility.
jq?jq. This video has a great explaination about how to usejq: youtube.com/watch?v=EvpwhGeiH0U