I read the following article "Using grep and sed to find and replace a string" but how can I extend it to chain multiple greps. For example I have the following directory/file structure
dir1/metadata.txt
dir2/metadata.txt
dir1/metadata.txt has
filename1 '= 1.0.0'
filename2 '= 1.0.0'
dir2/metadata.txt has
filename1 '= 1.0.0'
long_filename '= 1.0.0'
In other words, both dir1/metadata.txt and dir2/metadata.txt contain "filename '1.0.0'" but the spaces between the "filename" and the "'1.0.0'" in each file is different.
Now I want to replace filename1's associated version to '2.0.0' in ALL metadata.txt files so the resulting files look like...
dir1/metadata.txt has
filename1 '= 2.0.0'
filename2 '= 1.0.0'
dir2/metadata.txt has
filename1 '= 2.0.0'
long_filename '= 1.0.0'
I'm trying
find . -name metadata.txt | xargs grep filename1 | sed -i "s/1\.0\.0/2.0.0/g" <some option here>
but I know the "some option here" part. Any clues?