Replace using Perl

22 marzo 2008 at 11:51

Fecha Posted in Computers
Tags Tags: , ,

This tip probably seems a bit stupid, but I have always found very useful. If we want to replace a string in a file with another string, we can do it easily using Perl:

perl -p -i -e 's|old_string|new_string|' file.xml

Of course, if we need to apply it to several files we can use a wildcard character.

Comments (ADD YOURS)

  1. ¿Perl? ¿No hubiese sido más apropiado usar sed?
    http://www.ss64.com/bash/sed.html

    Saludos ;)

  2. También, también :)

    Saludos!

  3. "The Enlightened Ones say that you should never use C if you can do it with a script, never use a script if you can do it with awk, never use awk if you can do it with sed, and never use sed if you can do it with grep."

Write a comment



OpenID Sign In with OpenID