Yeah, I know, I could just use sed. But lets assume I'm some sort of sicko. A masochist if you will..
I have a file, /tmp/a.script, containing:
%s_"taxonomy\.php[^"]*\([0-9]\)_"\1.taxonomy_g
%s_"rtf\.php[^"]*\([0-9]\)_"\1.rtf_g
%s_"csv\.php[^"]*\([0-9]\)_"\1.csv_g
%s_"xml\.php[^"]*\([0-9]\)_"\1.xml_g
(I snarfed them from my vim history)
I would very much like vim to execute those commands against a file, say example.html.
But, I can't figure out how to execute this script against the file.
I'm aware of the -c command line argument. But it only executes a single command, I want to execute all these commands.
Any ideas?
Answer is below, for reference, a quick sed way to do it would be:
for i in *.html ; do
sed -i'' -e 's_"taxonomy\.php[^"]*\([0-9]\)_"\1.taxonomy_g' $i
sed -i'' -e 's_"rtf\.php[^"]*\([0-9]\)_"\1.rtf_g' $i
sed -i'' -e 's_"csv\.php[^"]*\([0-9]\)_"\1.csv_g' $i
sed -i'' -e 's_"xml\.php[^"]*\([0-9]\)_"\1.xml_g' $i
echo $i
done
sedexample: 1)-i''is equivalent to-idue to the way Bash processes quotes; 2) You can give-emultiple times, or separate thes///commands with semicolons, to avoid multiple sed calls; 3) You can give*.htmldirectly to sed. – grawity Mar 7 '12 at 21:24