Create Directories From String Array
I have an array of directory names. I wanna create directories from the array. This is my code.
WATCHED_MOVIE_LIST=("Tenet", "Inception", "Interstellar", "Arrival", "Escape Room")
mkdir ${WATCHED_MOVIE_LIST[*]}
This code will create directories like this.
Tenet
Inception
Interstellar
Arrival
Escape
Room
But Escape Room
is a single name. It must create a single folder called 'Escape Room'. However, I want to create directories like this
Tenet
Inception
Interstellar
Arrival
Escape Room
How do I do this in 2 lines of code? (One line is better)
Solution 1:
I found a way to do that by doing small changes to my code.
WATCHED_MOVIE_LIST=("Tenet", "Inception", "Interstellar", "Arrival", "Escape Room")
mkdir "${WATCHED_MOVIE_LIST[@]}"
# '*' replaced with '@'
# Added double quotations to ${WATCHED_MOVIE_LIST[@]}
This code can do my work. Thanks