[Top][All Lists]

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


From: Assaf Gordon
Subject: Re: PCRE
Date: Thu, 2 Nov 2017 14:11:47 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

(follow-up from a private message)

Hi Michael,

If all you need is sed's substitution command but want it with PRCE regex capabilities, the following is a quick way:

   perl -pe 's/ XXXX / YYYY /g' INPUT > OUTPUT
   perl -pe 's/ XXXX / YYYY /g' < INPUT > OUTPUT

"perl -e PROG" tells perl to execute PROG
instead of reading the perl script from a file (similar to "sed -e").

"perl -p" will run the specified command in an loop over
each line of the input file, and will print the current line
(after any modifications you made to it).

The following are equivalent:

  seq 10 |  sed -E -e 's/([2357])/Found prime: \1/g'
  seq 10 | perl -p -e 's/([2357])/Found prime: \1/g'

Of course I'm glossing over many details,
perl is much more complicated and powerful than sed - but hopefully
it'll get you started.

These could help as well:

 - assaf

reply via email to

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