You are not logged in.

#1 2009-03-08 08:37:11

muflax
Member
From: Germany
Registered: 2008-07-21
Posts: 58

redirect I/O to same file without temp file [SOLVED]

Is there a simple way to do the following?

command < file > file.tmp; mv file.tmp file

Basically, I'm looking for a command-agnostic "< file > file" that doesn't just truncate file.

I'm using zsh, if that matters.

Last edited by muflax (2009-03-10 01:36:24)

Offline

#2 2009-03-09 22:30:30

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: redirect I/O to same file without temp file [SOLVED]

Hi, i just uploaded a PKGBUILD[#1] for "rewrite" tool.

Usage: rewrite [-v] [-r "s/old/new/"] files.. "cat|cat"

        -v              verbose output (show compression ratios)
        s/old/new/      sed expression for renaming files

        files..         input file names to rewrite through pipeline
        "cat|cat"       pipeline expression to rewrite file through

This is a simple command for this purpose For example:

For example:

$ rewrite README "grep -v the"

[#1] http://aur.archlinux.org/packages.php?ID=24530

Last edited by djgera (2009-03-09 22:30:53)

Offline

#3 2009-03-10 01:36:05

muflax
Member
From: Germany
Registered: 2008-07-21
Posts: 58

Re: redirect I/O to same file without temp file [SOLVED]

Nice, thanks!

I'll mark this as solved, as there doesn't seem to be a way that relies only on the shell. But if someone has another idea, just post it. smile

Offline

Board footer

Powered by FluxBB