Sed with inplace editing changes group ownership of file
12
votes
5
answers
8173
views
I have shell (
php
) script that gets in touch with target file this way:
- inspects whether file and directory are writable with php
's is_writable()
(I don't think that this is problem)
- does in-place file edit with sed
command:
grep -q "$search" "$passwd_file" && { sed -i "s|$search|$replace|" "$passwd_file"; printf "Password changed!\n"; } || printf "Password not changed!\n"
As a result I get (everything else correct but) file which was myuser:www-data
to be myuser:myuser
.
Does sed
changes file group ownership as it seems, and how do I avoid it, if possible?
Asked by Miloš Đakonović
(1041 rep)
Apr 15, 2016, 08:01 AM
Last activity: Apr 29, 2024, 07:21 AM
Last activity: Apr 29, 2024, 07:21 AM