Question

i have been trying to create 100 folders with the names Client numbered 1-100 e.g. (client1, client2..client100) i also want to create a text file within each folder called client follwed by the same number on the folder. I have got to this peice of coding:

mkdir -p Client{1..100} && touch Client{1..100}/Client.txt

But this command line only generates a text file called client but is not numbered. Please can you help me figure out the coding to do this.

Thank you

Was it helpful?

Solution 2

Even more concise:

for x in Client{1..100}; do
    mkdir -p $x
    touch $x/$x.txt
done

OTHER TIPS

Try this:

for x in {1..100}
do
    mkdir -p Client$x
    touch Client$x/Client$x.txt
done

Instead of {1..100} you can use the seq command and get additional features. For example:

for x in `seq -w 1 100`
do
   ....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top