zoukankan      html  css  js  c++  java
  • 【linux命令】test

    1、表达式

    #!/bin/bash
    
    # if test 表达式1 【表达式为真】
    if test 1 == 1;then
     echo 'test 条件为真'
    fi
    # if test 表达式1 【等同于】 if [ 表达式1 ]
    if [ 1 == 1 ];then
     echo '[] 条件为真'
    fi
    # if test ! 表达式1        【表达式为假】
    if test ! 2 == 1;then
     echo 'test 条件为假'
    fi
    # if test 表达式1 -a 表达式2
    if test 1 == 1 -a 2 == 2;then
     echo '表达式1 和 表达式2 都为真'
    fi
    # if test 表达式1 -o 表达式2
    if test 1 == 1 -o 2 == 3;then
     echo '表达式1 或 表达式2 有一个为真'
    fi

    2、文件(夹)

    #/bin/bash
    for fileName in `ls`
    do
    if test -f $fileName;then
     echo $fileName '是文件'
    elif test -d $fileName;then
     echo $fileName '是目录'
    fi
    done
  • 相关阅读:
    UIView添加手势
    UIView常见属性设置汇总
    关于页面传值
    有关segue的简介
    alloc
    如何定义静态方法
    一座小城
    清明
    开通博客
    iOS学习之界面间传值
  • 原文地址:https://www.cnblogs.com/bxbyy/p/7985988.html
Copyright © 2011-2022 走看看