I have a scenario where multiple users are connected to a server using SSH. I have a file which is read and written by all the users.
The file contains numbers like this -
14554 14887 23451 15135 15154 15165 1236 1516 15616 9821 98715
now is the file was created by user
X and user
Y tried to executing the following command he gets an error:
sed -i '/14554/d' /tmp/file.txt sed: cannot rename /tmp/sedtm3Vhx: Operation not permitted
The file permissions reads as -
ls -l /tmp/file.txt -rwxrwxrwx. 1 USERX USERX 63 Apr 25 11:58 /tmp/file.txt
However if the user
Y opens the file, it is possible to read/write into the file. I think there are no permissions to delete or rename the file created by another user.
Will it be possible to remove this line which has the number
14554, without deleting or renaming file.
Sed was good because it would give me atomic access in case of multiple users trying to read or write the same file. This is one reason, I would also not like the
for loops in bash script to edit this file.