twhlai@watdragon.waterloo.edu (Tony Lai) (07/31/88)
A few weeks ago, a program called "hold" was posted to comp.sources.misc that buffers its input. The idea is that something like sed 's/a/b/g' foo > foo makes foo a null file, while sed 's/a/b/g' foo | hold foo changes all a's to b's in foo, because hold prevents foo from being overwritten before sed finishes reading foo. Here is a simple Bourne shell script to do this. #!/bin/sh # # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # The files contained herein are: # hold # echo 'extracting hold' if test -f hold; then echo 'shar: not overwriting hold'; else sed 's/^X//' << 'EOF' > hold X#!/bin/sh Xif [ $# -gt 1 ] Xthen X echo 'Usage: hold [file]' 1>&2 X exit 1 Xfi Xf=/tmp/hold.$$ Xcat > $f Xcase $# in X0) cat $f ;; X1) cat $f > $1 Xesac X/bin/rm -f $f EOF if test `wc -c < hold` -ne 158; then echo 'shar: hold was damaged during transit (should have been 158 bytes)' fi fi exit 0
wsd@whuts.UUCP (DINSMORE) (08/04/88)
In article <8082@watdragon.waterloo.edu> twhlai@watdragon.waterloo.edu (Tony Lai) writes: !A few weeks ago, a program called "hold" was posted to comp.sources.misc that !buffers its input. The idea is that something like ! sed 's/a/b/g' foo > foo !makes foo a null file, while ! sed 's/a/b/g' foo | hold foo !changes all a's to b's in foo, because hold prevents foo from being overwritten !before sed finishes reading foo. ! Would someone please me a way to do this in the C_Shell? Thanks, W. Dinsmore -- | Wayne S. Dinsmore Make it in Massachusetts, | AT&T Bell Labs (ihnp4,att,moss)!whuts!wsd Spend it in New Hampshire. | 20 Shattuck Road Room 4A-118 | Andover,Mass 01810
jerryp@cmx.npac.syr.edu (Jerry Peek) (08/08/88)
[Sorry for posting this. Mail to him bounced.] In article <4623@whuts.UUCP> wsd@whuts.UUCP (54299-DINSMORE,W.S.) writes: > > Would someone please me a way to do this in the C_Shell? Here it is. --Jerry Peek, Northeast Parallel Architectures Center, Syracuse, NY jerryp@cmx.npac.syr.edu +1 315 443-1722 ----- CUT HERE ----------------------------------------------------------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # hold.csh # This archive created: Mon Aug 8 10:26:18 1988 export PATH; PATH=/bin:$PATH if test -f 'hold.csh' then echo shar: will not over-write existing file "'hold.csh'" else cat << \SHAR_EOF > 'hold.csh' #! /bin/csh -f if ( $#argv > 1 ) then # USE sh TO PUT ERROR ON stderr: sh -ce "echo 'Usage: hold [file]' 1>&2" exit 1 endif onintr cleanup set f=/tmp/hold.$$ cat > $f switch ($#argv) case 0: cat $f; breaksw case 1: cat $f > "$1"; breaksw endsw cleanup: /bin/rm -f $f exit 0 SHAR_EOF chmod +x 'hold.csh' fi # end of overwriting check # End of shell archive exit 0
rasasoft@funman.UUCP (09/20/88)
> twhlai@watdragon.UUCP writes ( 5:14 am Jul 31, 1988 in funman:ALT.SOURCES): > Subject: hold -- a program to buffer input > A few weeks ago, a program called "hold" was posted to comp.sources.misc that > buffers its input. The idea is that something like > sed 's/a/b/g' foo > foo > makes foo a null file, while > sed 's/a/b/g' foo | hold foo > changes all a's to b's in foo, because hold prevents foo from being overwritten > before sed finishes reading foo. > > Here is a simple Bourne shell script to do this. > > #!/bin/sh > # > # This is a shell archive. Remove anything before this line, > # then unpack it by saving it in a file and typing "sh file". > # > # The files contained herein are: > # hold > # > echo 'extracting hold' > if test -f hold; then echo 'shar: not overwriting hold'; else > sed 's/^X//' << 'EOF' > hold > X#!/bin/sh > Xif [ $# -gt 1 ] > Xthen > X echo 'Usage: hold [file]' 1>&2 > X exit 1 > Xfi > Xf=/tmp/hold.$$ > Xcat > $f > Xcase $# in > X0) cat $f ;; > X1) cat $f > $1 > Xesac > X/bin/rm -f $f > EOF > if test `wc -c < hold` -ne 158; then > echo 'shar: hold was damaged during transit (should have been 158 bytes)' > fi > fi > exit 0