Reputation: 161
i have text file :
"NAME": "Linda",
"AGE": "34",
"NAME": "Arnold",
"AGE": "99",
and i want to get arnol's age : 99
i try this --> cat file.txt | grep "AGE" | sed -n 2p
output : "AGE": "99",
how can i output only 99?
thanks
Upvotes: 0
Views: 72
Reputation: 627100
You may replace your sed
command with
sed -n '2 s/.*"\(.*\)".*/\1/p'
It will extract just the value in the last pair of quotes.
See an online demo.
Upvotes: 1