Tag Info

New answers tagged

0

With tcsh, you can use ${%var} construct to check number of characters in variable var: if (${%var} == 0) then echo 'var is empty' endif


2

if ("$myVar" == "") then echo "the string is blank" endif Note that in csh, it is an error to attempt to access an undefined variable. (From a Bourne shell perspective, it's as if set -u was always in effect.) To test whether a variable is defined, use $?myVar: if (! $?myVar) then echo "myVar is undefined" else if ("$myVar" == "") then echo ...


1

You can use test(1). For example: % test -z "$myVar" && echo "the string is blank" or % [ -z "$myVar" ] && echo "the string is blank" Both assume that $myVar is set.



Top 50 recent answers are included