Home > Mobile >  how to create same multiple file in multiple dirrectory?
how to create same multiple file in multiple dirrectory?

Time:04-29

suppose I have 3 dirrectories named dir1,dir2,dir3.And I want to touch 3 same files(f1.txt,f2.txt,f3.txt) in each dirrectories(dir1,dir2,dir3).how can I do that with one command? dir1 -f1 -f2 -f3 dir2 -f1 -f2 -f3 dir3 -f1 -f2 -f3

CodePudding user response:

Simply use curly braces around the directories and files when creating the files with touch

touch {dir1,dir2,dir3}/{f1.txt,f2.txt,f3.txt}

Also see this question

touch command create multiple files (different names) under one directory

CodePudding user response:

I'm not sure I understand your question;

If you just need to create those 9 files in one command, simply use

touch dir1/f1.txt dir1/f2.txt dir1/f3.txt dir2/f1.txt ...
  • Related