Re: set the tmp file for sed??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux