having this command:
$ find / -path /home/oldroot -prune -o -name config.yml -exec sed -i'' '/(swipe)|(pinch)/s/[0-9].*/1/' {} \+
won't edit:
couldn't open temporary file /home/shepherd/.config/fusuma/sedSQVSZd: Permission denied
You can say, it does not work because of sudo. But it does not even work with sudo, the point is the -i
flag here.
find
found file /fusuma/config.yml
, but -i
change it into /fusuma/sedSQVSZd
as sideeffect of in-place edditing. So is there a way to persist filenames with sed?
sed
writes the result of the edits into before replacing the original file (this is how "in-place" editing works). The user runningsed
does not have permission to create the temporary file in that location. Can you show the permissions and ownerships on/home/shepherd/.config/fusuma
,/home/shepherd/.config
,/home/shepherd
and/home
and let us know what user is executing that command? – Kusalananda♦ May 16 '20 at 23:06/home/
, which is as usual owned by root. The command is run by sudo privileges – Herdsman May 16 '20 at 23:25sed
command without the pipe on the file directly?sed -i'' '/(swipe)|(pinch)/s/[0-9].*/1/' /home/shepherd/.config/fusuma/config.yml
– Kusalananda♦ May 17 '20 at 16:23