Unix菜单shell脚本:向.tar添加、列出和提取文件
我正在尝试创建一个基于菜单的脚本,它有3个选项 1.将文件添加到.tar 2.列出.tar的内容 3.提取tar文件内容 这就是我目前所拥有的。我还是unix新手,所以是的Unix菜单shell脚本:向.tar添加、列出和提取文件,shell,unix,menu,terminal,tar,Shell,Unix,Menu,Terminal,Tar,我正在尝试创建一个基于菜单的脚本,它有3个选项 1.将文件添加到.tar 2.列出.tar的内容 3.提取tar文件内容 这就是我目前所拥有的。我还是unix新手,所以是的 #!/bin/sh #script2 PS3='Enter your choice: ' options=("Option 1: Add file to .tar" "Option 2: List contents of .tar" "Option 3: Extract contents"$ select
#!/bin/sh
#script2
PS3='Enter your choice: '
options=("Option 1: Add file to .tar" "Option 2: List contents of .tar" "Option 3: Extract contents"$
select opt in "${options[@]}"
do
case $opt in
"Option 1")
echo "you chose choice 1"
tar -rf file.tar file2add
;;
"Option 2")
echo "you chose choice 2"
tar -tf file.tar
;;
"Option 3")
echo "you chose choice 3"
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done
[IMG]http://i42.tinypic.com/29gen0o.png除非你真的希望你的脚本以最小的依赖关系工作(即只使用<代码> SH ),考虑使用一个程序,使编程文本模式菜单变得更容易。 StAcExver支持语法高亮显示。你能把你的密码放在你的帖子里吗?还有,你有什么问题吗?嗯,我正试图得到做上述功能的选项,我只是不断得到这是一个无效的选项。