On Thursday, October 25, 2012 11:37:33 AM UTC-5, Michael Young wrote:
> Hello!
>     I am attempting to use vim in a shell script to read in a file, edit it, 
> and write it out to a new file.  When I manually execute the individual vim 
> commands it seems to work properly but when I put the commands in a script 
> file and try to use that, the commands don't seem to work.  My shell script 
> generates a recursive file directory listing.  I then want to use vim to edit 
> the listing to replace any spaces in each file path with \space.  I am 
> including the shell below.  HELP!
> Thanks!
> Michael
> 
> #!/bin/sh
> 
> # Generate a recursive list of full pathnames for all filenames that do not
> # begin with a "."
> find "$1" -type f -and \! -name ".*" > filelist1
> 
> # Generate the input script for the vim editor
> # Go through the "find" listing and replace every " " with "\ "
> cat << EOF > vimscript
> :%s/ /\\ /g
> :wq! md5shell
> EOF
> 
> # Execute vim with the generated input script
> vim -s vimscript filelist1

Your cat command does not create the file you expect. Garbage in, garbage out. 
I did the cat command by hand and got a file with contents:

:%s/ /\ /g
:wq! md5shell

Note the lack of a second \ character.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to