Input file
..
set name "old name"; # comment "should be updated"
..
Output file
..
set name "new name" ; #comment "should be updated"
..
when i tried to grep the content between quotes with grep -i 'name' inputfile | grep -P \".+{\"} its grepping content between first ” and last “
i.e old name"; # comment "should be updated
any idea to accomplish that using grep, sed or awk!
It’s unclear exactly what you’re trying to do. For one thing, your
grepcommand includes a curly brace and the input doesn’t. Also, it appears that you want to make a substitution based on a comparison of your input and output.However, taking your question literally, here’s how you can
grepthe strings between the quotes. You can use non-greedy matching:Example:
Edit:
In order to substitute a value, you can use
sed. You would not usegrep.Example: