1 thought on “How to replace a string in multiple files in Linux command line

  1. 1) You can use the ‘replace’ utility that comes with MySQL.

    2) You can use the ‘sed’ utility as follows:

    # create a couple of test files
    $ for i in 1 2 3; do printf ‘file %d\n’ $i >f$i; done

    # show the contents
    $ cat f[123]
    file 1
    file 2
    file 3

    # change the files
    $ sed –expression=s/file/FILE/g –in-place f[123]

    # show the contents
    $ cat f[123]
    FILE 1
    FILE 2
    FILE 3

    # clean up
    $ rm f[123]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

Recent Comments

Archives

Categories

Meta

GiottoPress by Enrique Chavez

%d bloggers like this: