lundi 23 mars 2015

how to check the string is Null or not in shell script?


I had a script like this



#!/bin/bash
line="hello"

if [ -z $line ] ; then
echo "String null"
fi


This will work properly, but when I give the lineas follows



line="hello welcome"


It will through the error as



a.sh: 5: [: hello: unexpected operator


In that situation , how can I check that is Null or no ??



Aucun commentaire:

Enregistrer un commentaire