zoukankan      html  css  js  c++  java
  • vim编辑shell

     
    vi编辑
    u撤销
    i输入
    dd删除游标所在的那一整行(常用)
    yy复制游标所在的那一行(常用)
    p 为将已复制的数据在光标下一行贴上
    nyy n 为数字。复制光标所在的向下 n 行,例如 20yy 则是复制 20 行(常用)
    n查找下一处
    /向后搜索?向前搜索
    :set nu    显示行号,设定之后,会在每一行的前缀显示该行的行号
    :set nonu    与 set nu 相反,为取消行号!
     
    显示行号
    输入命令:
        set nu
    或者
        set number
    取消显示行号
    命令:
        set nonu
    或者
        set nonumber
     
    chown:更改文件属主,也可以同时更改文件属组
    chmod:更改文件9个属性
     
     
    shell脚本流程
    if
     
    if condition
    then
        command1
        command2
        ...
        commandN
    fi
     
    if  else
     
    if condition
    then
        command1
        command2
        ...
        commandN
    else
        command
    fi
     
    if else-if else
     
    if condition
    then
        command1
        command2
        ...
        commandN
    else
        command
    fi
     
    for 循环
     
    for var in item1 item2 ... itemN
    do
        command1
        command2
        ...
        commandN
    done
     
    while 语句
    while condition
    do
        command
    done
    until 循环
    case
    case 值 in
    模式1)
        command1
        command2
        ...
        commandN
        ;;
    模式2)
        command1
        command2
        ...
        commandN
        ;;
    esac
     
    break命令continue命令与break命令类似,只有一点差别,它不会跳出所有循环,仅仅跳出当前循环。
    case的语法和C family语言差别很大,它需要一个esac(就是case反过来)作为结束标记,每个case分支用右圆括号,用两个分号表示break。
    跳出循环
  • 相关阅读:
    L2-004. 这是二叉搜索树吗?
    CF934A A Compatible Pair
    CF937B Vile Grasshoppers
    CF940B Our Tanya is Crying Out Loud
    ZOJ 3182 Nine Interlinks
    ZOJ 3175 Number of Containers
    Codeforces Round #193 (Div. 2) B
    CodeForces 149D Coloring Brackets
    POJ 2653 Pick-up sticks(计算几何)
    UVA 12506 Shortest Names
  • 原文地址:https://www.cnblogs.com/h-c-g/p/10722755.html
Copyright © 2011-2022 走看看