[CentOS] Feed a list of filenames to vim

Wed May 18 13:54:20 UTC 2011
Jason Pyeron <jpyeron at pdinc.us>

> -----Original Message-----
> From: centos-bounces at centos.org 
> [mailto:centos-bounces at centos.org] On Behalf Of Bowie Bailey
> Sent: Wednesday, May 18, 2011 9:55
> To: centos at centos.org
> Subject: Re: [CentOS] Feed a list of filenames to vim
> 
> On 5/18/2011 12:50 AM, Jussi Hirvi wrote:
> > On 17.5.2011 19.36, Bowie Bailey wrote:
> >> Try this:
> >>
> >> vim `cat list`
> > Thanks, this really works! I tried it with all my combinations:
> >
> > OS X workstation by itself
> > OS X workstation -> ssh -> CentOS 4
> > OS X workstation -> ssh -> CentOS 5
> >
> > BTW, with the xargs command, all of these combinations give some 
> > problems. The cause may have something to do with my 
> terminal settings.
> > Anyway, now I can use `cat list`.
> 
> The problem is that you were screwing up vim's stdin.  Using 
> the method I gave you, you are just taking advantage of shell 
> features to provide a list of filenames to vim on the command line.
> 
> If your list looks like this:
> 
> file1
> file2
> file3
> 
> Then when you do "vim `cat list`", the shell expands it to this:
> 
> $ vim file1 file2 file3
> 
> You can also do this:
> 
> $ 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.



--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.