zoukankan      html  css  js  c++  java
  • shell编程

    #!/bin/sh
    #当前程序的名称
    echo $
    0
    #当前程序的第n个参数
    echo $
    1
    #当前程序的所有参数
    echo $*
    #当前程序的参数个数
    echo $#
    #当前程序的PID
    echo $$
    #执行上一个指令的PID
    echo $!
    #上个指令的返回值
    echo $?

    #!/bin/sh
    #shell中字符串的比较
    s1=
    "abc "
    s2=
    "abc"
    s3=
    "bcd"
    s4=
    ""
    if [
    "$s1"="$s2" ];then
    echo "s1等于s2"
    fi
    if [
    "$s2"!="$s3" ];then
    echo "s2不等于s3"
    fi
    if [ -n $s1 ]
    ;then
    echo "s1不为空"
    fi
    if [ -z $s4 ]
    ;then
    echo "s4为空"
    fi
    #---------------------霸气的分割线------------------------#
    #shell整数的判断
    i1=
    1
    i2=
    2
    i3=
    1
    if [ $i1 -eq $i3 ]
    ;then
    echo "i1等于i3"
    fi
    if [ $i2 -ge $i1 ]
    ;then
    echo "i2大于等于i1"
    fi
    if [ $i2 -gt $i1 ]
    ;then
    echo "i2大于i1"
    fi
    if [ $i1 -le $i2 ]
    ;then
    echo "i1小于等于i2"
    fi
    if [ $i1 -lt $i2 ]
    ;then
    echo "i1小于i2"
    fi
    if [ $i1 -ne $i2 ]
    ;then
    echo "i1不等于i2"
    fi
    #---------------------霸气的分割线------------------------#
    #shell判断文件
    if [ -d
    "abc" ];then
    echo "abc是一个目录"
    fi
    if [ -f
    "shell.sh" ];then
    echo "shell.sh是一个文件"
    fi
    if [ -e
    "abc" ];then
    echo "abc存在"
    fi
    if [ -r
    "pthread.o" ];then
    echo "pthread.o为进程的可读文件"
    fi
    if [ -s
    "shell.sh" ];then
    echo "shell.sh长度不是0"
    fi
    if [ -w
    "shell.sh" ];then
    echo "shell.sh为进程可写文件"
    fi
    if [ -x
    "shell.sh" ];then
    echo "shell.sh可执行"
    fi
    if [ -L
    "shell.sh" ];then
    echo "shell.sh可符号化链接"
    fi
    #!/bin/bash
    clear
    for((i=1;i<100;i++))
    for
    do
    if((i%3==0))
    then
    echo
    $i
    continue
    fi
    done
    #!/bin/bash
    clear
    for i in `seq 100`
    do
    if((i%3==0))
    then
    echo
    $i
    continue
    fi
    done
    #!/bin/bash
    clear
    i
    =1
    while(($i<100))
    do
    if(($i%3==0))
    then
    echo
    $i
    fi
    i
    =$(($i+1))
    done

    a

    a

    a

    a

    a

    a

    a

    aa

    a


















  • 相关阅读:
    布局管理器
    下拉列表框
    时间,日期选择器
    关于部分基本控件的使用
    关于Activity
    什么时候修改class
    JavaScript Break 和 Continue 语句
    JavaScript While 循环
    JavaScript For 循环
    JavaScript Switch 语句
  • 原文地址:https://www.cnblogs.com/ggzwtj/p/2115055.html
Copyright © 2011-2022 走看看