Package: moreutils
Version: 0.22
Severity: important

    % man sponge | grep DESC -nA 4
    11:DESCRIPTION
    12-       sponge  reads  standard  input and writes it out to the specified 
file.
    13-       Unlike a shell redirect, sponge soaks up all its input  before  
opening
    14-       the  output file. This allows for constructing pipelines that 
read from
    15-       and write to the same file.

Let's try such a pipeline, here's the before 'sponge' version, with
separate input and output files:

    % F=/tmp/nums ; seq 1 100000 > $F ; wc $F ; cat $F | sort > ${F}2 ; wc ${F}2
    100000 100000 588895 /tmp/nums
    100000 100000 588895 /tmp/nums2

And 2 different 'sponge' versions, (with and without 'cat'), with
a pipeline that reads and writes from and to the same file:

    % F=/tmp/nums ; seq 1 100000 > $F ; wc $F ; sponge < $F | sort > $F ; wc $F
    100000 100000 588895 /tmp/nums
    0 0 0 /tmp/nums
    % F=/tmp/nums ; seq 1 100000 > $F ; wc $F ; cat $F | sponge  | sort > $F ; 
wc $F100000 100000 588895 /tmp/nums
    0 0 0 /tmp/nums

Last, the 'cat' version, without 'sponge'

    % F=/tmp/nums ; seq 1 100000 > $F ; wc $F ; cat $F | sort > $F ; wc $F
    100000 100000 588895 /tmp/nums
    0 0 0 /tmp/nums

As can be seen, 'sponge' has the same effect as no 'sponge'.

Hope this helps...


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.21-1-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C)
Shell: /bin/sh linked to /bin/dash

Versions of packages moreutils depends on:
ii  libc6                         2.6-2      GNU C Library: Shared libraries
ii  perl                          5.8.8-7    Larry Wall's Practical Extraction 

moreutils recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to