On 26Sep2015 16:39, bruce <badouglas@xxxxxxxxx> wrote:
I know. This is probably really basic/subtle, but 'net searches are
coming up empty.
Doing testing of 'sed' it's generating tmp files in the base
directory. Is there a way that the 'sed' tmp dir can be set to '/tmp'.
A sample sed cmd would be
sed -i '/foo/cat/g' abc.dat
sed -i '/foo/d' abc.dat
I'm presuming you're using GNU sed (from the -i); if not, please say so.
IIRC, sed -i makes a temp file with the new content, then renames it to the
original. This allows for an atomic in place edit, as opposed to a rewrite
which will leave the file incomplete for a period (or might fail half way
through, etc).
In order to ensure that a rename can be done the temp fie has to be on the same
filesystem as the original, and the simple way of doing that reliably is to
make the temp file in the same directory as the original.
If you need the temp file elsewhere (eg for size) you could use a wrapper. For
example, bsed (disclaimer: yes, this is mine):
https://bitbucket.org/cameron_simpson/css/src/tip/bin/bsed
which does a rewrite. It honours the $TMPDIR environment variable for the temp
directory.
Cheers,
Cameron Simpson <cs@xxxxxxxxxx>
--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org