Say I have a file with 2 rows, named file.txt:
Row 1: 80 is a nice number Row 2: 80 is a cool number Row 3: 80 is a piquant number Row 4: 80 is a sexy number
sed -i 's/80/8080/g', but by mistake I ran it twice and the result in all rows was
80808080 instead of just
I believe it is most likely impossible in the common technology but I still want to ask if maybe, there is a sophisticated way to make
sed do it's effect only once on this file. I mean, some kind of "lock" that will avoid happening of such mistakes like running this
sed more than one time one the file, until I remove tat lock. This might (and I emphasis the word "might") be helpful when dealing with much longer rows, especially in large amounts.
It's not really a problem and I should avoid such a mistake and that's it, but I am curious to know if someone try to develop some technical "defense mechanism" from such
Note: I believe a similar solution could be helpful to
awk users as well.