Trouble with sed replace


#1

I have a need to change my path to perl in all my cgi-bin perl scripts (https://discussion.dreamhost.com/thread-136493.html) but I can’t figure out why I’m having so much trouble. Using a ssh session from a new WIN 7 PC with Putty, I made a backup copy of my cgi-bin directory, then started working on the backup copy. I changed to the directory, put a line of sed in a file using vi s:/usr/local/bin/perl:/usr/bin/perl:

Then ran it with the line sed -f path.sed *.cgi

On the terminal screen I get a bunch of the first couple perl scripts flash by, then lots of binary code, then lots of “Putty” repeated over and over. And the path doesn’t get changed in my perl scripts.

I wonder if I have all my terminal settings correct in Putty on this new PC, because all my # comment characters appear as the English pound sign in my putty window. I cranked up the old PC and they appear as # in that old install of Putty. Can’t find any differences in the terminal setup between PCs.


#2

If you want “sed” to edit files in place, you’ll need to add the -i option. Otherwise it just applies the changes and prints the results to the terminal.

As far as your £ issues go, that’s probably a terminal setting that’s been inadvertently triggered by the binary junk that got printed to it. (Which is, in turn, probably because you were trying to apply sed to some compiled C programs, not just Perl.) Open up a new terminal and it should be fine.


#3

Thanks, that worked on both issues.