Main Menu
    • Home
    • Business Partners
    • Customers
    • Contact Us
    Services
    • Performance Engineering
    • Test Management
    • Technology Consulting
    • Networking
    • Education & Training
    • KnowledgeBase
      • PERL
      • DOS/Windows
      • LoadRunner
    Key Concepts
    • Broadband
    Home KnowledgeBase PERL Global Search and Replace in Unix

    Global Search and Replace in Unix

    PostDateIconThursday, 20 November 2008 11:27 | PostAuthorIconWritten by Mark

    The following code will perform a global search and replace in UNIX.

    perl -p -i -e 's/oldstring/newstring/g' $(find . -name \*.fileext)

    The parameters mean the following:

    • -p = assume loop like -n but print line also, like sed (-n = assume "while () { ... }" loop around program)
    • -i = edit files in place
    • -e = precedes each line of the program (in this case 's/oldstring/newstring/g')
    • $(find . -name \*.fileext) = do this for all file names matching *.fileext in the current drectory
     

    Copyright © 2010 DowdTec Ltd

    Joomla template created with Artisteer by Mark Dowd.