M
Monica
Guest
I need to do some in-place editing, and sed just isn't getting the job done, so I must turn to Perl. I will be working with very large files, so I cannot monkey about with making copies of them or anything.
My script looks like this:
perl -p -i -e 's|[search expression]|[replacement value]|g' [filename]
The file name is an argument for my script, which will be run in the C-Shell. (It has to be; this will go in the middle of a larger tool that does other C-Shell things.)
I know -p makes the perl command apply to every line, but I want it to work on just lines with a particular line number. How do I do that?
Come to think of it, it'd be great if I could use the same command to edit multiple lines at a time so the computer only has to make one temporary file.
The files my script will be editing will have hundreds of thousands of lines in them, so it's important that I don't have to make a new file every time I need to change a line.
My script looks like this:
perl -p -i -e 's|[search expression]|[replacement value]|g' [filename]
The file name is an argument for my script, which will be run in the C-Shell. (It has to be; this will go in the middle of a larger tool that does other C-Shell things.)
I know -p makes the perl command apply to every line, but I want it to work on just lines with a particular line number. How do I do that?
Come to think of it, it'd be great if I could use the same command to edit multiple lines at a time so the computer only has to make one temporary file.
The files my script will be editing will have hundreds of thousands of lines in them, so it's important that I don't have to make a new file every time I need to change a line.