Tag Archives: bash

How to check if a variable is set in Bash?

where ${var+x} is a parameter expansion which evaluates to nothing if var is unset, and substitutes the string x otherwise. To check for non-null/non-zero string variable, i.e. if set, use It’s the opposite of -z. I find myself... Read More | Share it now!

Bash Shell中命令行选项/参数处理

0.引言 写程序的时候经常要处理命令行参数,本文描述在Bash下的命令行处理方式。 选项与参数: 如下一个命令行: ./test.sh -f config.conf -v –prefix=/home 我们称-f为选项,它需要一个参数,即config.conf,... Read More | Share it now!