In bash, the standard current Linux shell, your single quotes have to balance out. In your example above, you have three single quotes. Four of them would balance out, but not three. You can see this if you change your code:
to:perl -p -i -e 's/ where/' where/g' *.sql
This probably will not give you the results you expect (though it's "shell-correct"), because the quoting is actually still incorrect for your target results.# Note the second single-quote below perl -pi.orig -e 's/ where/'' where/g' *.sql
There is also an interesting change I put in the second example. Note the '-pi.orig' change there. What that does is create a file called 'foo.sql.orig' for every file changed by your substitution (assuming foo.sql was one of your files). When you're dealing with files and substitutions "in-place" like that, it's good to make a backup.
NOTE: If you run this a second time, your backup file will be overwritten by your second copy, trashing your backup. It's always good to have backups somewhere else, but if you're doing a one-time pass, using -pi.orig is a good way to do that.
The suggestion from Chmrr is correct in this case, you need to change how your quoting is passed to the shell. You do not have to do this if this change was inside a perl script running under bash, however.
There are several documents on the web that can help you understand this a bit more:
Hope that helps.
In reply to Re: Inserting a single-quote into a file
by hacker
in thread Inserting a single-quote into a file
by chuntoon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |