Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a file 'filelist' that contains the following lines:

text1.txt
text2.txt
text3.txt 

I am looking for a command line invocation that opens the 3 files in vim. I tried the following:

$ cat filelist | vim - 

and

$ vim < cat filelist

but those do not yield the desired result.

share|improve this question
    
Try vim $(cat filelist). –  vonbrand Apr 12 '13 at 14:01

3 Answers 3

If the file names don't contain spaces or other problematic characters, you can use

vim $(cat filelist)

For file names with spaces, using xargs is more robust (here using GNU xargs specific options):

xargs --delimiter '\n' --arg-file=filelist vim --
share|improve this answer
    
What a quick answer! Great :) I found another solution on this site using backticks (on the same key as the ~ sign). Here it is: unix.stackexchange.com/a/5882/37057 –  user37057 Apr 12 '13 at 13:52
1  
$(…) is the same as backticks, but a little more robust, since they can't be confused with single quotes or other similar looking characters and they can be nested. –  Marco Apr 12 '13 at 13:54
    
The xargs one affects the stdin of vim. –  Stéphane Chazelas Apr 12 '13 at 15:03

With zsh:

vim -- "${(f)$(<filelist)}"

With any Bourne-like shell (including zsh):

(IFS='
'; set -f; exec vim -- `cat filelist`)

With GNU xargs:

xargs -d '\n' --arg-file=filelist vim --
share|improve this answer

To open all index.php in the current working path

vim -p `find . -name index.php`
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.