Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There comes a point at which <code>sed</code> is no longer the correct tool for the <a href="https://stackoverflow.com/questions/366980/what-are-the-differences-between-perl-python-awk-and-sed">job</a>. I think this task has reached that point (but see the clever <a href="https://stackoverflow.com/questions/9053632/passing-part-of-patterns-from-sed-to-shell/9054367#9054367">answer</a> by <a href="https://stackoverflow.com/users/967492/potong">potong</a> which shows that it can be done with <code>bash</code> and <code>sed</code>).</p> <p>Which alternative tool do you use? You don't show the function, but if it can be conveniently calculated in the shell with a shell function, the chances are that <code>awk</code> is powerful enough to do the job. I'd probably fall back on Perl myself, but Python (or Ruby) would also work well. All of these allow you to write a function, to read the data and apply the function to the data before writing the data back out.</p> <p>The problem with trying to use a function in <code>sed</code>is that it has no mechanism to define functions or to execute shell functions. To use <code>sed</code>, you'd have to think in terms of two passes through the data, the first extracting the (unique) tokens for subsequent processing, which would be to apply the shell function to each token, <em>generating</em> a <code>sed</code> script which simply matches each token and substitutes it with its replacement, followed by applying that script in the second pass over the data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload