I need to add file.txt to all root directories and display path them.
I was tried to use
touch /home/folder1/file.txt & touch /home/folder2/file.txt etc.
but maybe someone can help me to make it simpler?
CodePudding user response:
If your shell supports it (and most shells do, e.g. Bash and Zsh), you can use brace expansion, e.g.:
touch /home/folder{1..10}/file.txt
CodePudding user response:
Simple one -
touch /home/{folder1,folder2}/file.txt
This is known as expansion, another answer to a similar issue here - https://unix.stackexchange.com/questions/435621/bash-brace-expansion-after-a-path-slash
Ben Voigt's answer is essentially the same - breat me to it, though it also shows you how you can use a range of numbers...
My answer will do exatly what you asked, hoever if you wanted folders 1-10 then Ben's answer is better...