1

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)

0
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.