LinuxCommandLine -- [脚本 - case]

2018-04-30  本文已影响0人  liaozb1996
case test_variable in
    pattern1 | pattern2) commands;;
    pattern1 | pattern2) commands;;
    *) commands;;
esac

.py 结尾的文件,用 python 执行;
.sh 结尾的文件,用 bash 执行
其他文件,用 less 查看其内容

#!/bin/bash

shell=/bin/bash
python=/bin/python

case "$1" in
    *.py) $python $1
    ;;

    *.sh) $shell $1
    ;;

    *) less $1
    ;;
esac
上一篇 下一篇

猜你喜欢

热点阅读