0

I would like to know if anyone can help me with this. I would like to search a text file for a certain line of text, add a new line under the specific line then add text to the new line. I will be using this to edit the firefox.js file to add the line of text to add support for Iprism. It will run on XP and Windows 7 machines.

I would like to have a batch file that will open firefox.js find the line "pref("browser.xul.error_pages.expert_bad_cert", false);" add a new line uder it and add pref("network.automatic-ntlm-auth.trusted-uris", "IP of Iprsim");

Edited for better explanation!!

Any help would be very appreciated!!!

Damian

2
  • 1
    What operating system/shell would this be running under? Commented Nov 10, 2009 at 15:53
  • 1
    The batch tag is either SQL batch processing or the Windows command processor cmd.exe. It's rarely something entirely else and most UNIX/Linux users don't call their shell scripts batch files. Commented Nov 10, 2009 at 15:57

1 Answer 1

1

You can iterate over lines in a file with for /f. You need to keep track of the line you're currently at, compare it to what you look for and in case you found the line you were looking for do something. This something looks roughly as follows: You output each line you process to stdout or a new file directly and when you find your desired line you do exactly the same but write something else to that new file as well. At the very end you simply delete your old input file and rename the new one.

In a batch file this might look somehow like the following (untested, so careful):

for /f %%x in (inputfile) do (
    echo %%x>>newfile
    if ("%%x"=="Ex3") (
        echo Ex4>>newfile
    )
)

del inputfile
ren newfile inputfile

Of course, adapt as you see fit.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.