I'm curious to hear what people think about tbe best way to edit files automatically in a script.
I'm making edits to a number of lines in a file (10+ lines need changing). It's straightforward editing which never varies so it's easy to do but what method would you use?
The way I'm doing it is by using a series of (single operation) sed statements each time writing the output to a temporary file (in /tmp), then editing that file & writing to another file (in /tmp). I toggle between these 2 files until I'm finished then send the output to the file I want to use.
I do this because I find it easier to document internally & I expect others to find it easier to maintain.
I could use a long string of sed commands which no doubt could be more efficient but I think would be harder for others to read.
There will be lots of ways to do this & I'm curious what your views are. Maybe I'm missing a neat, efficient but also easily read method? I consider maintainability to be the main priority as it's not going to be a long, processor intensive operation.
Thanks, Chris
I'm making edits to a number of lines in a file (10+ lines need changing). It's straightforward editing which never varies so it's easy to do but what method would you use?
The way I'm doing it is by using a series of (single operation) sed statements each time writing the output to a temporary file (in /tmp), then editing that file & writing to another file (in /tmp). I toggle between these 2 files until I'm finished then send the output to the file I want to use.
I do this because I find it easier to document internally & I expect others to find it easier to maintain.
I could use a long string of sed commands which no doubt could be more efficient but I think would be harder for others to read.
There will be lots of ways to do this & I'm curious what your views are. Maybe I'm missing a neat, efficient but also easily read method? I consider maintainability to be the main priority as it's not going to be a long, processor intensive operation.
Thanks, Chris