in reply to Re^2: regex is not producing desired output
in thread regex is not producing desired output

I tried it, but it did not change anything in the file

ikegami's script the the correct way to do it. It doesn't change anything in the file, rather it opens the file handle for output only. If you want to modify the file, that's a totally different procedure and isn't pertinent to the question that you asked about the regex.

  • Comment on Re^3: regex is not producing desired output

Replies are listed 'Best First'.
Re^4: regex is not producing desired output
by Khen1950fx (Canon) on Jan 26, 2010 at 05:42 UTC
    Here's a way to modify a file in place:

    First, make a copy of your file and put it on your desktop. In this example, I called it apache.txt.
    Second, open a terminal.
    Third, from the cmdline, enter:

    perl -pi.orig -e 's/\bis\b/are/gi' /user/Desktop/apache.txt
    It'll modify the original file and create a new apache.txt. It'll save the original as apache.txt.orig.