I have file /some/foo which is a plain text file. I can edit it with vim and I can cat something else to it. But whenever I try to automate the editing process with sed, it says
sed: cannot move '/some/sedGl29Uj': Device or resource busy
I tried redirecting sed's output to a temporary file and cat, it's OK. But if I try to move the temporary file onto it, it will say
root@localhost:/some # mv tmp foo
mv: Device or resource busy
I'm quite concerned why vim and cat can write the file but mv can't.
Ubuntu 16.04.1 LTS. /some is a subfolder of / (root mount point, ext4).
mv ./tmp foo– Mike Waters Apr 23 '17 at 14:50vimandcaton the one hand, andsed -iandmvon the other hand, is thatcat >/some/foowrites to the existing file, whereasmv /some/foo /some/barrenames the file. This file can be written to, but can't be renamed. To understand why the file can't be renamed, we'd need to know more about this file and the filesystem that it's on and what OS you're running. – Gilles 'SO- stop being evil' Apr 23 '17 at 22:10