编写shell脚本难免遇到需要交互式输入指令的步骤: 方法一: # cat action.sh #!/bin/sh read -p "enter number:" no; read -p "enter number:" name; echo you have entered $no,$name; # sh action.sh enter number:chavin enter number:king you have entered chavin,king # ec…
在编写shell脚本中,经常要处理一些输入参数,在使用过程中发现getopts更加方便,能够很好的处理用户输入的参数和参数值. getopts用于处理用户输入参数,举例说明使用方法: while getopts :a:b:cdefg opt; do case $opts in a) do sth; ...... cde) do another; esac done 几个重要变量: OPTIND:getopts使用OPTIND作为索引,…
非常棒!! 非常棒!! 删除ctrl + d 删除光标所在位置上的字符相当于VIM里x或者dlctrl + h 删除光标所在位置前的字符相当于VIM里hx或者dhctrl + k 删除光标后面所有字符相当于VIM里d shift+$ctrl + u 删除光标前面所有字符相当于VIM里d shift+^ctrl + w 删除光标前一个单词相当于VIM里dbctrl + y 恢复ctrl+u上次执行时删除的字符ctrl + ? 撤消前一次输入alt + r 撤消前一次动作alt + d 删除光标所在…
expect一般用于实现用脚本来自动远程登录,对远程机器执行相关操作 测试机上的expect目录一般在/usr/bin/expect路径 下面是从网上查询的用法总结: 1. expect中的判断语句: if { condition } { # do your things } elseif { # do your things } else { # do your things } expect中没有小括号(),所有的if/else, while, for的条件全部使用大括号{}, 并且{ 与左…
test命令用法.功能:检查文件和比较值 shell中test命令方法详解 原文:https://www.cnblogs.com/guanyf/p/7553940.html 1)判断表达式 if test (表达式为真) if test !表达式为假 test 表达式1 –a 表达式2 两个表达式都为真 test 表达式1 –o 表达式2 两个表达式有一个为真 2)判断字符串 test –n 字符串 …