|
shell script help (vim)
I am trying to write a shell script that will paste a named buffer to many files. a very simple script to prove my problem is this:
The Shell Script
-----------------------------------------------
#!/bin/bash
vim -e -s file.htm < change
exit
-----------------------------------------------
The file with vim commands (file name being "change")
-----------------------------------------------
pu a
x
-----------------------------------------------
I am, of course, trying to paste buffer 'a' into the file named "file.htm". however, when i open the file "file.htm" no change has taken place. to double check myself I have opened up the file "file.htm" in ex mode and simply typed in the commands "pu a" and "x" manually, and sure enough, it does exactly what i want it to do. however, I want the shell script to do this for me.
I am simply trying to get the script to paste a line of code into many html files.... so eventually the script will look more like this
The Shell Script
-----------------------------------------------
#!/bin/bash
for file in *.htm; do
vim -e -s $file < change
done
exit
-----------------------------------------------
where hundreds of .htm files will be awaiting their fate. as of yet, no luck. i have even tried changing the file "change" to read this
-----------------------------------------------
norm "ap
x
-----------------------------------------------
thinking that maybe it would work in normal mode... however it does not. hopefully this is a simple fix... i could easily make the code a macro but then i would have to open up every individual file... bleh.
obviously the shell script will do much more, but everything else I want it to do works perfectly. this is the only part I seem to be having trouble with. as i have said, I can manually open up each individual file and paste 'buffer a' in... so i am certain that 'buffer a' holds the contents i wish to paste. why will it work manually, but not in the shell script?
Last edited by thepimpturtle89; 08-20-2006 at 08:32 PM.
|