sed is deleting Text file on mounted network drive

  • Hi,

    i'm trying to add or search/replace text to a text file that is stored on a network device that is mounted in LibreELEC. I have this error:

    Code
    sed -i 's/text1/text2/g' /var/media/fritzbox/file.txt
    sed: can't move '/var/media/fritzbox/file.txtusnupr' to '/var/media/fritzbox/file.txt': Permission denied

    It looks like sed is trying to create a temp file (file.txtusnupr) and failed when renaming the temp file to the real file name. Both files (temp file and source file doesn't exists after running sed). I have this problem with sed in general when the source file is on the network device. It works with local files. But it's no problem to create or delete or edit a text file with cat or nano.

    This is the output of 'ls -lh'

    Code
    drwxr-xr-x    4 1000     1000        4.0K Jun 23  2023 data1
    drwxr-xr-x    9 root     root       36.0K Oct  4 17:18 data2
    drwxr-xr-x    2 root     root           0 Mar  3 22:03 fritzbox
  • Go to Best Answer
  • I'm not sure what the underlying issue is, but the workaround will be to redirect the output of sed to a new file and then move the new file to the original filename and perform the change in two steps not one.

    Does the fritzbox samba server log anything?

  • Quote

    I'm not sure what the underlying issue is, but the workaround will be to redirect the output of sed to a new file and then move the new file to the original filename and perform the change in two steps not one.

    I'll try it.

    I don't think the Fritzbox is the problem. This works with all my other devices in the same way. When doing the same from my notebook it's the same "slow" fritzbox.