I have a file named test
:
[test@mypc ~]$ ls -i
4982967 test
Then I use vim to change its content and enter :w
to save it.
It now has a different inode:
[test@mypc ~]$ ls -i
4982968 test
That means it's a different file already, why would vim save it to another file as I use :w
to save to the original one?
You see, echo to a file will not change the inode, which is expected:
[test@mypc ~]$ echo v >> test
[test@mypc ~]$ ls -i
4982968 test
It is trying to protect you from disk and os problems. It writes out a complete copy of the file, and when it is satisfied this has finished properly, renames this file to the required filename. Hence, new inode number.
If there were a crash during the save process, the original file would remain untouched, possibly saving you from losing the file completely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With