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?
Asked
Active
Viewed 81 times
2 Answers
3
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
muru
- 207,228
2
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.
muru
- 207,228