zoukankan      html  css  js  c++  java
  • 14.shell脚本学习

    简单的执行跟踪,会使得Shell显示每个被执行到的命令
    sh -x delete.sh

    查找与替换
    grep
    sed -i "s/t_rs_customer/t_rs_customer_bak/g" t_rs_customer_bak.sql 

    使用cut选定字段
    cut -d : -f 1,5 /etc/passwd
    cut -d : -f 6 /etc/passwd

    使用awk重新编排字段
    默认一空白分隔字段
    awk '{print $1}' delete.sh
    awk '{print $1,$3}' delete.sh
    设置字段分隔符
    awk -F : '{print $1,$3}' /etc/passwd

    计算行数、字数以及字符数
    wc -l,wc -w,wc -c

    if-elif-else-fi语句
    if pipeline
       [pipeline ... ]
    then
       statements-if-true-1
    [ elif pipeline
       [pipeline ... ]
    then
       statements-if-true-2
    ]
    [ else
       statements-if-all-else-fails
    ]
    fi

    case语句
    case var in
    exp-1) 命令体1 ;;
    exp-2) 命令体2 ;;
    ...
    *)    命令体 ;;
    esac

    for循环
    for i in {1..10}
    do
       echo $i
    done
    i=1
    while(($i<100))
    do
        if(($i%4==0))
        then
            echo $i
        fi
        i=$(($i+1))
    done

    函数是指一段单独的程序代码,用以执行一些定义完整的单项工作
  • 相关阅读:
    dnsever 邮件记录
    用于显示上个月和下个月_PHP
    JSON学习
    ASP生成新会员编号
    godaddy_关于产品退款
    Switch Case语句中多个值匹配同一个代码块的写法
    网闸与防火墙的比较
    bench.sh 跑分测速
    Kcptun加速SS
    linux 安全狗
  • 原文地址:https://www.cnblogs.com/allenhu320/p/11284552.html
Copyright © 2011-2022 走看看