I'm new to Linux and would like to create a new directory based on the user's input for the folder name. How can I also create a new directory, inside the first directory by asking for a name from the user again?
Code:
#! /bin/bash
echo "Enter name of dir":
read folder1
mkdir -p $folder1
touch docu.dat
chmod 755 docu.dat
I try to see the list of directory that was created with the command ls
, but I did not see the list, and I wonder why.
I also want to know how I should execute the script file using bash parameters. Please help me correct it.
echo "Enter another name:"; read folder2
)? What else is missing? And what do you mean by "execute the script using bash parameters"? Do you mean pass the directory names as arguments to the script instead of asking the user for input? – terdon Jun 25 '21 at 08:55