shell判断一个变量是否为空方法总结 https://www.jb51.net/article/154835.htm 1.判断变量 复制代码代码如下: read -p "input a word :" wordif [ ! -n "$word" ] ;then echo "you have not input a word!"else echo "the word you input is $word"fi 2
脚本如下: #!/bin/bash mysql -s -phello test >.log <<EOF desc t1; EOF lines="concat_ws(','," count=`.log|wc -l` linenum= while read line do coloumname=`echo $line |awk '{print $1}'` let linenum=linenum+ ];then lines=$lines"concat_ws(':'
需求描述: 写shell脚本的过程中,有时会需要获取脚本的名字,比如,有的时候,脚本 中会有usage()这种函数,可能就会用到脚本的名字. 实现方法: shell脚本中,通过使用$0就可以获取到脚本的名字或者说脚本本身. 操作过程: 1.通过以下的脚本写了一个脚本的使用函数usage() #!/bin/bash #function usage means how to use this script. usage() { echo "Usage: $0 process_name1"