0

I'm sorry if this is a very basic question, but I cannot find out how to do this for the life of me. I'm trying to create a loop to create folders with user prompts until the text command "end" is input. For example, I would input the folder name for my semester as "Spring 2019" and then create sub directories for each class. Every article I find for loops shows me how to create a loop on a set amount of folders, but nothing that will stop with an input. Can anyone point me in the right direction, unfortunately I have nothing to even start with so any help is appreciated.

2

1 Answer 1

0

Following script read folder name and create it in a loop. You can exit entering empty folder name, or Ctrl-C. It will also create nested folders if input like "aaa/bbb/ccc".

#!/usr/bin/env bash

while true; do
  read -p "Folder name:" input
  [[ -z "$input" ]] && break
  mkdir -p "$input"
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .