在 shell 中表示逻辑 or 可以使用 -o:

    1. #!/usr/bin/bash
    2. echo $0 $1 $2
    3. if [ -f $1 -o -f $1.html ]; then
    4. echo 'exist!'
    5. else
    6. echo 'does not exist!'
    7. fi

    将脚本存为 hello

    $1 表示用户输入的第一个参数,如:

    1. $ hello world # world 为 $1

    worldworld.html 存在时,打印 exist!