test a sed command?

Joseph Sinclair plug-discussion at stcaz.net
Tue Sep 13 21:45:35 MST 2011


The default for sed is to output the results to stdout.
If you just leave out the option to write back to the original file, wouldn't that work as a test?
Alternatively you could pipe the sed output into diff against the original file
Something like this:
"sed -e '<command>' infile | diff infile -"


On 09/13/2011 09:00 PM, Dazed_75 wrote:
> How do people test sed replacements on something consequential?  I thought I
> remembered sed having an option to just report what changes it WOULD HAVE
> made without actually making the changes.  But I can't find anything like
> that.
> 
> Best I can think of is to make a test directory [hierarchy], copy your files
> into it, run the sed command and then look at all the files for intended and
> unintended changes (or diff them from the originals).  That would seem to
> suck!
> 
> 
> 
> 
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20110913/4ef31f75/attachment.pgp>


More information about the PLUG-discuss mailing list