unix - sed command to find a pattern and replace with quotes -
how fina pattern below replace using sed command
find (examples)
"students": 98, "students": 17, "students": 200, "students": 21,
replace
"students": "98", "students": "17", "students": "200", "students": "21",
if want put quotes around numbers, can use
sed -e 's/([0-9]+)/"\1"/g'
if want after "students":
, can use
sed -e 's/("students": )([0-9]+)/\1"\2"/g'
-e
means extended regular expression follows.
s/
means substitution being made, /
delimiter.
\1
matches first parenthesized part of regex, , /2
matches second parenthesized part, etc.
-g
applies substitution every match found
Comments
Post a Comment