我想用shell脚本交互式创建文件夹,例如:先提示输入文件夹的名称,输入后再创建,怎么能实现呢

2024-11-13 10:39:08
推荐回答(2个)
回答1:

代码为:
1 #!/bin/bash
2
3 read -p "dirname:" a
4 read -p "make dir now?[y/n]:" select
5 read select

6 if [ $select = "y" ]
7 then
8 mkdir $a
9 else
10 echo nothing to do;
11 fi

回答2:

#!/bin/bash
echo "pls input directory"
read a
mkdir $a