I'm trying to find and replace text across multiple files. I'll need to do this for a lot of text (ugh) and I found this beautiful one liner
perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt
This works great for what I'm doing, so I wanted to make it a little simpler to run. First, I thought I could just make a bash function, something like this:
function replace{
perl -pi -w -e 's/$1/$2/g;' *$3
}
But that gives me plenty of errorsbash: .bashrc: line 110: syntax error near unexpected token `perl' bash: .bashrc: line 110: ` perl -pi -w -e 's/$1/$2/g;' *$3'
Soo, I thought it might be smarter to make a perl script... but how do I do that??? I tried this
#!/usr/bin/perl -w 's/$ARGV[0]/$ARGV[1]/g;'but obviously only met failure. Admittedly, it's been a LONG time since I've used perl, and I've never done anything like this. I definitely could use some help!
This post has been edited by atraub: 02 October 2012 - 01:56 PM

New Topic/Question
Reply



MultiQuote






|