如何在Bash脚本中使用case
时间:2019-08-20 17:58:20 来源:igfitidea点击:
示例
#/bin/bash echo "Give Full Path where the file is located" read pth echo "Give the file name" read fle if [ -f $pth/$fle ];then echo "$fle file is found in $pth" else echo "$fle file not found in $pth" echo "U r going to exit in 2seconds" sleep 2 exit fi echo "Do u want to delete the file (Y/N)" read xyz case $xyz in Y|y) rm -fr $pth/$fle;; [Yy][Ee][Ss]) rm -fr $pth/$fle;; N|n) exit;; [Nn][Oo]) exit;; *) exit;; esac