perl -pi -e "s/.*/DELETE FROM my_object_times where ID = '$1';/g" ids.csv
Since the Perl snippet is in double-quotes, the shell will expand
$1 to whatever its current value is (probably empty or unset in your case). You need to escape the dollar sign to prevent that. Also, you don't have a capture group in the pattern of the
s/// operator, so
$1 would not contain anything. (
perl -w or
use warnings would warn you about this.)
Either add parenthesis to the pattern, or use
Also, the global replacement doesn't seem to work well with a pattern that can be zero-width, so I'd suggest removing the
perl -w -pe "s/.*/DELETE FROM my_object_times where ID = '\$&';/"
& is not a valid variable in shell, so
$& will be left as-is. But in general, the
$ would need to be escaped.)
Usually, putting the Perl code in single-quotes would be better, as the dollar sign is quite common in Perl. But here the single quotes inside the Perl code make that a bit hard. One option is to present them in hex:
perl -w -pe 's/.*/DELETE FROM my_object_times where ID = \x27$&\x27;/'