Path: csiph.com!aioe.org!news.glorb.com!usenet.stanford.edu!not-for-mail From: Bob Proulx Newsgroups: gnu.utils.bug Subject: Re: 'sed -i' fails if the file has sufficient perms but not its directory Date: Fri, 3 Jul 2015 19:51:06 -0600 Lines: 38 Approved: bug-gnu-utils@gnu.org Message-ID: References: <5596D2E9.2000007@gmx.de> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: usenet.stanford.edu 1435974674 11626 208.118.235.17 (4 Jul 2015 01:51:14 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-gnu-utils@gnu.org To: Toralf =?iso-8859-1?Q?F=F6rster?= Envelope-to: bug-gnu-utils@gnu.org Mail-Followup-To: Toralf =?iso-8859-1?Q?F=F6rster?= , bug-gnu-utils@gnu.org Content-Disposition: inline In-Reply-To: <5596D2E9.2000007@gmx.de> User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 216.17.153.58 X-BeenThere: bug-gnu-utils@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU utilities List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: aioe.org gnu.utils.bug:2183 Toralf F=F6rster wrote: > I tried this, which won't work : >=20 > tinderbox@tor-relay ~ $ sed -i -e 's/j1/j2/g' perl-5.22/etc/portage/mak= e.conf > sed: couldn't open temporary file perl-5.22/etc/portage/sedw9SFZf: Perm= ission denied Correct. If you want to use -i you will need write permission to the directory. This is the same as other tools such as perl -i and awk -i to= o. > whereas I'm allowed to edit that file as the user tinderbox >=20 > tinderbox@tor-relay ~ $ vi perl-5.22/etc/portage/make.conf The behavior depends upon the vi implementation. Some read it into memory, some into spill files in /tmp, some into .swp files in the same directory. > /me wonders if sed relies on having a temp copy of that file in the sam= e dir or not. The documentation for sed says this: '-i[SUFFIX]' '--in-place[=3DSUFFIX]' This option specifies that files are to be edited in-place. GNU 'sed' does this by creating a temporary file and sending output to this file rather than to the standard output.(1). ... When the end of the file is reached, the temporary file is renamed to the output file's original name. The extension, if supplied, is used to modify the name of the old file before renaming the temporary file, thereby making a backup copy(2)). Bob