Greg Sabino Mullane on Tue, 20 Nov 2001 21:50:15 +0100 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > the contents get wiped out... As others have said, it's a shell issue. The problem is that sed is a stream editor and reads line by line (or rather, makes a single pass over the input). Therefore, it can't read from a file while it is writing it at the same time. The only way is to store it into memory or use a temp file. Here's a little bash script I came up with to allow you to 'inplace edit' commands that don't have that option (such as 'sort'): #!/bin/bash --norc HESED=${!#} SHESED=`mktemp /tmp/$HESED.XXXXXX` $@ > $SHESED mv $SHESED $HESED Name it 'inplace', throw it in your path, and you should be able to do the following: inplace sed s/class=\"bodytext\"//g computing.php > ...a shell-script solution was presented to allow this sort of > thing without having to make a temporary file either before or > after. I don't quite see how it is possible to solve this without a temporary file, but would love to learn how if you can find the script. Thanks, Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200111201537 -----BEGIN PGP SIGNATURE----- Comment: http://www.turnstep.com/pgp.html iQA/AwUBO/rAVrybkGcUlkrIEQIRlgCgjrLCmg/vQ3mhU/seCbizVkiWhAMAn16U vgxjLH0aMc2bfvt0QHTC5v+I =YevP -----END PGP SIGNATURE----- ______________________________________________________________________ Philadelphia Linux Users Group - http://www.phillylinux.org Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce General Discussion - http://lists.phillylinux.org/mail/listinfo/plug
|
|