sed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Feature to add


From: Russell Harper
Subject: Feature to add
Date: Wed, 18 Jul 2018 15:19:39 -0400

I find I often have to write custom utilities, for example, something to
parse floating point in other bases and it would be great to be able to use
them within sed.

For example, I can illustrate with factor, a utility to factor numbers:

    $ factor 230
    230: 2 5 23

Right now there's no non-fragile way for me to make use of this in sed. For
example, a flag x to indicate to run the command and copy standard output:

    $ sed -E 's/([0-9]+)/factor \1/xg' <<< 'These are factors of numbers:
230, 19, 27, and 13.'
    These are factors of numbers: 230: 2 5 23, 19: 19, 27: 3 3 3, and 13:
13.

I checked in sed, awk, perl and others and posted on discussion groups.
None of them have a simple and robust way to do this. The only solution
using sed basically replaces with $(factor \1), wraps in double quotes and
gets echo to reevaluate the entire string! Very fragile if there are stray
$ anywhere.

Anyway, I hope you agree this would be a very useful and powerful feature
to have in sed.

Kind regards,

Russell


reply via email to

[Prev in Thread] Current Thread [Next in Thread]