Question

I have a bunch of configuration files used by gradle. conf1 conf2 conf3 conf4 etc. Sometimes I need to change some setting in every file or in several files. Is there any tool(for Linux) that helps me to do that?

For example, if I want set settings1 in conf2, conf3 and in conf5 I would use something like "set settings1=value in conf2,conf3,conf5"

Was it helpful?

Solution

You could do it with sed. Needing to change some but not all of a set of similarly-named files in a folder complicates it a bit:

find . -name conf2 -o -name conf3 -o -name conf5 | xargs sed -i 's/settings1=/settings1=value/g'

If you were changing all of the conf files you could just do this:

sed -i 's/settings1=/settings1=value/g' conf*

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top