0

I do this command:

$ locate config.yml | while read i; do sed -i '/(swipe)|(pinch)/s/[0-9].*/1/' $i; done

output:

sed: couldn't open temporary file /home/user/.config/fusuma/sedHhlVCW: Permission denied
sed: couldn't open temporary file /home/var/lib/gems/2.5.0/gems/fusuma-0.11.1/lib/fusuma/sed41YvwW: Permission denied
sed: couldn't open temporary file /var/lib/gems/2.5.0/gems/fusuma-1.10.0/lib/fusuma/sedFSNXeV: Permission denied

So I did with sudo (run as sudo sudo su -> #, but then not all files were change, and as I see from the error above, the files are temporary and with changed name (postfix of all them consist of command and random chars), does this pipe? If so why? How can I persist filenames over pipe?

$ uname -a
Linux user 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2 (2020-04-29) x86_64 GNU/Linux

$ type sed
sed is aliased to `sed -E'
Andy Dalton
  • 13,993
Herdsman
  • 340
  • See https://unix.stackexchange.com/questions/106663/how-to-run-a-command-that-involves-redirecting-or-piping-with-sudo -- prefixing the command with sudo will not cause sed to run under a different user – Torin May 15 '20 at 20:04
  • I actually did not prefix command with sudo, but rather run as sudo (with sudo su), like # comand ... – Herdsman May 15 '20 at 20:06
  • What Unix are you using, and do you know what sed implementation you're working with? – Kusalananda May 15 '20 at 20:11
  • Did not know these information is needed, will add them to the post – Herdsman May 15 '20 at 20:13
  • 2
    You might want to replace the $i with "$i" to avoid expanding arguments – Torin May 15 '20 at 20:14
  • Ok, but still, quoting is not the issue i think – Herdsman May 15 '20 at 20:15
  • The sedXXXXX files are likely due to the implementation of sed -i. This usually works by writing to a temporary file and then replacing the target file, rather than writing to the target file directly – Torin May 15 '20 at 20:15
  • @Torin but otherwise, the result would not save, but thanks, I thought it is caused by the pipe – Herdsman May 15 '20 at 20:20

0 Answers0