[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 'sed -i' fails if the file has sufficient perms but not its director
From: |
Jim Meyering |
Subject: |
Re: 'sed -i' fails if the file has sufficient perms but not its directory |
Date: |
Fri, 3 Jul 2015 15:02:48 -0700 |
On Fri, Jul 3, 2015 at 11:22 AM, Toralf Förster <address@hidden> wrote:
> I tried this, which won't work :
>
> address@hidden ~ $ sed -i -e 's/j1/j2/g' perl-5.22/etc/portage/make.conf
> sed: couldn't open temporary file perl-5.22/etc/portage/sedw9SFZf: Permission
> denied
>
> whereas I'm allowed to edit that file as the user tinderbox
>
> address@hidden ~ $ vi perl-5.22/etc/portage/make.conf
>
> /me wonders if sed relies on having a temp copy of that file in the same dir
> or not.
Yes, sed -i does require write access to each directory
containing a file that it modifies. That is necessary so that
the temporary file it creates can be renamed atomically back
onto the original, assuming all processing is successful.