2

I'm trying to save some work by editing multiple files with the same name located in different directories:

$ mkdir -p directory_{0..10}/results

How may I create files with the same name in all directories. For example,

$ vim/kwrite directory_*/results/output.txt
  • are you trying to open them for editing or just create them? What you have there will work for editing with vim if the files exist: vim directory_*/results/output.txt – user1794469 Jul 3 '15 at 16:35
  • I would also like to edit them. – Sebi Jul 3 '15 at 16:45
4

You almost have it with your second command. You did it correctly with the first, just use the same shell sequence expansion:

vim directory_{0..10}/results/output.txt

You should see something in the shell about opening 11 files. Then you can use vim to iterate through each one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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