$ cat file
aa
Baa
CaaD
$ sed -i -e 's/aa/AA/' file
$ echo $?
0
$ cat file
AA
BAA
CAAD
$ sed -i -e 's/aa/AA/' file
$ echo $?
0
This sed command exit status in both the cases whether it modifies or not is same and it is returning the same exit status as 0. I would like to have it as 0 if it changes and 1 in case if haven't modified anything.
If grep command return 0 if it found some string and return 1 if it does not , Same way if sed command modifies the file it has to return 0 and sed command doesn't modify anything then it has to return 1
I tried to use sed internal 'q' command but it didn't helped. Please help me.