Omar Ahmad Omar Ahmad - 1 year ago 44
Linux Question

Extract some characters from a file using sed

I have a text file that contain some information that I need to extract, an example file is as follows:

"version": (2, 0, 0),
"location": "Node Editor",
"category": "Node",

I want to get the version info in the form 2.0.0. I tried doing it by sampling the line and then sampling the version numbers and then combine them, but it was messy. What is the best way to do this?

tso tso
Answer Source
sed -n 's/.*\"version\":[^(]*(\(.*\)).*/\1/p' |sed 's/, /\./g'


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download