binary operator expected error when checking if a file with full pathname exists

后端 未结 2 1899
春和景丽
春和景丽 2020-12-10 13:45
pathname=$(cat $HOME/.rm.cfg)
if [ ! -z $pathname/$1 ]

.rm.cfg is a file that contains the following directory

2条回答
  •  -上瘾入骨i
    2020-12-10 14:07

    I had faced same error binary operator expected where I am getting more then one word for some variable.when I used it as mention below.

    if [ ! -z ${variable} ];
    

    So for resolve this error I changed it to :

    if [[ ! -z ${variable} ]];
    

提交回复
热议问题