0
I am trying to create a series of folders on my computer that start with strings from "01" to "20".
To do this, I created a list of strings and applied the command mkdir
in an iteration:
declare -a names=("02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20")
for i in "${names[@]}"
do
mkdir $i_txtfiles
done
But this code is not working and returns the error mkdir: missing operand
.
I tried using the folder name as string and it didn’t work either. How can I create multiple folders on my computer and name them with the values of a list?
mkdir $i_txtfiles
, the idea was to generate folders with the name02_txtfiles
,03_txtfiles
, etc.?– Woss
Yes. Exactly
– Lucas
So I think it should be
mkdir $i\_txtfiles
, for Bash not to consider_txtfiles
as part of the variable name. Ormkdir ${i}_txtfiles
– Woss
Well, it worked. I had tried to create the folders without the "_" and it hadn’t worked either, but now with the escape it worked. Thanks
– Lucas
when it is so just exchange the command for an echo and see what is being printed, serves to test any type of basic interpolation
– Bacco