Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在开发一个 shell 脚本,它是一个菜单驱动的界面。其中一个选项要求用户输入可选文件或目录的列表,然后代码将在检查它们是否为有效文件和目录后将其删除。代码的目标是理解菜单驱动的界面。
我的问题是读取文件和目录名称列表。似乎 sh 不支持数组。这个问题的解决方案是什么?
2) echo "enter the name of files want to be deleted: " read files . . ;;
2) echo "enter the name of files want to be deleted" read a for CHARACTER in $a ; do if [ -f $CHARACTER -o -d $CHARACTER ] ; then rm -ir $CHARACTER else echo "$CHARACTER is not a valid file or directory" fi done ;;