Reputation: 186552
In my bash_profile
I have this:
function ht() { perl -i -pe 's|<!-- Mirrored from (.*?) -->\n||' "$a" ;}
I want to run ht
to do an inline replacement on the file fed to remove an HTML Comment with the HTTrack signature, but when I run this,
ht file.html
I get:
Can't open : No such file or directory.
I suspect this is because of the quotes around my $a which interfere with the perl
command being fed. Perhaps it prefixes the "
literally to the filename, or something of this nature and overall it becomes the wrong filename.
I tried removing the double quotes around my $a
but that doesn't seem to do what I want. How can I resolve this?
Upvotes: 0
Views: 611
Reputation: 5737
You have to tell perl what file you're trying to run with. Change to this:
function ht() { perl -i -pe 's|<!-- Mirrored from (.*?) -->\n||' "$@";}
Note the $@
instead of "$a" at the end. As @jwd points out, that's even better than $*
in most cases.
Upvotes: 3