I am using below command to open, replace, view the change and save a file:
sed 's/old string/new string/g' filename > filename1; diff filename1 filename; mv filename1 filename
Is it possible to ask for a confirmation before executing mv
command, something like below?
sed 's/old string/new string/g' filename > filename1
diff filename1 filename
<Some-Command here for user to provide Yes or NO confirmation>
mv filename1 filename
The intent is to validate the change and only then save it.