编写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 删除光标所在
1. 基本概念(这是理解后面的知识的前提,请务必理解) a. I/O重定向通常与 FD有关,shell的FD通常为10个,即 0-9: b. 常用FD有3个,为0(stdin,标准输入).1(stdout,标准输出).2(stderr,标准错误输出),默认与keyboard.monitor.monitor有关: c. 用 < 来改变读进的数据信道(stdin),使之从指定的档案读进: d. 用 > 来改变送出的数据信道(stdout, stderr),使之输出到指定的档案: e. 0 是 &
作者:iamlaosong 我们常常在shell脚本程序中用<<EOF重定向输入.将我们输入的命令字符串作为一个运行程序的输入,这样,我们就不须要在那个程序环境中手工输入命令,以便自己主动运行我们须要的功能,比如: sqlplus emssxjk/emssxjk <<EOF select count(*) from sncn_yxyj where create_date like sysdate; EOF 当中的SQL语句相当于在sqlplus程序环境中输入的.这样输入的内容夹在两