Question: I am trying to replace string in a file using this command in a script:-

```
sed -i "find replace" file_name

```

But the file permissions are getting changed after this.

Please help

Answer: 
Permissions are preserved on my Fedora system. In any case, you can tell `sed` to keep the old file around. Then you can copy the permissions over:

```
sed -i.old "find replace" file_name
chmod --reference file_name.old file_name
rm file_name.old

```
* Reproduced in ubuntu 16.04 (No AD) using `sed -i`
* The permission are changed to `---x-----x` randomly
* SOLUTION: put `sleep 1` after `sed` command :)