AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
#Operatingsystems
#Servers
 View Only
  • 1.  one command to replace all

    Posted 02/23/12 01:23 PM

    Originally posted by: leahcim


    Hi All,

    I use the command
    find . -type f -exec sed 's/pattern_a/pattern_b/' {} \;
    to find all files in the current and sub directories which has pattern_a and replace it with pattern_b.

    The command did not really do the work, though. It does not replace the pattern in the file; it just print it out on the screen.

    Could any one help on this point to improve this one line command to save me from writing a script, thanks in advance.

    Best regards,
    leahcim
    #AIX-Forum


  • 2.  Re: one command to replace all

    Posted 02/24/12 08:22 AM

    Originally posted by: cikuraku


    maybe you could try this one;
    find . -type f | xargs perl -pi.bak -e 's/string1/string2/g'
    #AIX-Forum


  • 3.  Re: one command to replace all

    Posted 03/23/12 11:17 AM

    Originally posted by: morr


    find . -type f -exec ex -c '1,%s/pattern_a/pattern_b/g' -c ':wq' \{\} \;
    #AIX-Forum