How to create 100 files with the names a1, a2, a3, .... a100 in the terminal? Can this be done in one team?
1 answer
the greatest “complexity” is to get a sequence of numbers. to add them with letters and hand them over to the touch program is simple.
As far as I know, the posix standard does not have any “onboard” tools that simplify the generation process. You can use some universal language:
using the awk program:
$ awk 'BEGIN { for(i=1;i<=5;i++) printf "a%d\n", i }' a1 a2 a3 a4 a5to create files, just transfer the list to the touch program:
$ touch $(awk 'BEGIN { for(i=1;i<=5;i++) printf "a%d\n", i }')using the bc program:
$ echo 'for (i=1; i<=5; i++) {print "a",i,"\n"}' | bc a1 a2 a3 a4 a5to create files, just transfer the list to the touch program:
$ touch $(echo 'for (i=1; i<=5; i++) {print "a",i,"\n"}' | bc)in the gnu operating system, there is a seq program that just simplifies the generation:
$ seq -f 'a%g' 1 5 a1 a2 a3 a4 a5to create files, just transfer the list to the touch program:
$ touch $(seq -f 'a%g' 1 5)well, modern “heaped” bash / zsh shells understand the
{1..5}construct:$ echo {1..5} 1 2 3 4 5those. you can create files again by passing the list to the touch program:
$ touch a{1..5}
touch a{1..100}in bash, for example - Alexey Ten