[Top][All Lists]

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

Re: sed suggestion: sed C API

From: Assaf Gordon
Subject: Re: sed suggestion: sed C API
Date: Sun, 8 Jul 2018 20:39:45 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

Hello Charlie,

On 08/07/18 01:58 PM, Charlie Sale wrote:
Recently, I have started learning about the SED tool. Although I have
used it before, I haven't quite grasped how to use it and have instead looked around for prewritten SED commands to do what I wanted. I want to change that now and learn more about the command.

In case you are still looking for examples, there is a wealth of
information here:
And of course many available books.

There is always the official gnu sed manual:

and if you find it lacking, please let us know what improvements
would you suggest for the manual to help someone new to using sed.

As I've been learning about it, I thought it might be useful for the
command to have a C API. I was thinking that it would basically take
the functionality of the command line tool and package it into a C

What would be the benefit of a C api for gnu sed ?

It seems to me most high-level scripting languages (e.g. perl / python
/ ruby / php / javascript / lua) already contain their own library
functions to perform actions similar to what sed can do.

Similarly many modern non-scripting language (e.g. java, rust, go,
swift, etc) have their own regex library and powerful text replacement

For C++ there is boost's regex module (combined with STL's file
streams), and the C++11 standard regex templates.

For C, there are the posix regex functions (should be available on
almost any modern operating system).

There are some existing regex libaries out there with binding
to many languages, e.g.:
 PCRE (,
 Google's RE2 ( library)
 Oniguruma (

Lastly, there are some people who already maintain such libraries,
though I can't attest to how reliable or well-maintained these are:

And of course, there is always the option of just executing "sed"
from your program.

SED offers more than just regex support, but then every programming
language has its own paradigm about file/text processsing.

Maintaining a stable C api library takes some effort (in terms
of software development and maintenance) - not sure this effort is

Do you have a specific use-case in mind where a C-api to GNU sed
would be useful ?

I am not very familiar with the SED source, but I'd be happy to learn
about it.

A useful place to start is this "OpenGrok" server which
allows easy navigation and exploration of SED source code.

 - assaf

reply via email to

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