[CentOS] Feed a list of filenames to vim

Bowie Bailey Bowie_Bailey at BUC.com
Wed May 18 15:06:47 UTC 2011


On 5/18/2011 10:42 AM, Michael Gliwinski wrote:
> On Wednesday 18 May 2011 15:09:19 Bowie Bailey wrote:
>>>> $ vim `ls -1 *.txt`
>>>>
>>>> or this:
>>>>
>>>> $ vim `find /some/dir -name '*.txt'`
>>>>
>>>> It works with any command that outputs a list of filenames.
>>> Until you have a space in a filename.
>> True.  But unless vim has a null-separator option for command line
>> arguments, I don't know of a way to automate that case.
> How about just:
>
>   $ vim *.txt
>
> or, if you need recursive:
>
>   $ eval vim $(find /some/dir -type f -printf '"%p" ')
>
> (shell quotes expansions automatically, but you can still ensure output from 
> find is appropriately quoted manually)

Interesting.  I'm not sure what the eval is doing, but it works even
with spaces in the filenames.  Unfortunately, it won't work with the
OP's original scenario (a file with a list of filenames to edit).

-- 
Bowie



More information about the CentOS mailing list