I have a file in which some lines contain a json object on a single line, and I want to extract the value of the window_indicator
property.
A normal regular expression is: "window_indicator":\s*([\-\d\.]+)
in which I want the value of the fist match group.
Here it is working perfectly well: https://regex101.com/r/w9Iuch/1
I've settled on sed
because it seems that grep
has to print the whole line and can't limit to the match group value, and perl
is overkill.
Unfortunately, sed
isn't actually capable of doing this, is it?
# sed 's/("window_indicator:)/\1/' in.txt
sed: -e expression #1, char 26: invalid reference \1 on `s' command's RHS
# sed -E 's/("window_indicator":)/\1/p' in.txt
prints out every line of the file
# sed -rn 's/("window_indicator":)/\1/p' in.txt
prints the whole line
# sed -rn 's/("window_indicator":)/\1/' in.txt
nothing