I need to add one file to about 7 different directories. I'm using Fedora 24... I know I need to use the touch command but what parameters will I need?


2 Answers 2


Use brace expansion in bash:

touch {dir1,dir2,dir3,dir4,dir5,dir6,dir7}/file

If the directories are named after a pattern, you might even be able to generate that. For example, if the directories were actually named like on the command above:

touch dir{1..7}/file

If directories are different use this:

touch {d1,d2,d3,d4,d5,d6,d7}/file_name

Or you can use this one:

touch dir{1..7}/file_name

This command creates file in dir1, dir2, ... dir7 respectively.

Not the answer you're looking for? Browse other questions tagged .