The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 12-06-2007
pagod pagod is offline
Registered User
 

Join Date: Dec 2007
Posts: 2
checking for empty string in tcsh

Hi,

i'm writing a script in tcsh, and i need to check to see whether a string is empty. i think sh users use the -z function for this, but i'm using it already to check for the emptiness of a file -- surely it's not the same function for both, is it?

is there another one to check for string emptiness, or am i wrong in using it to check for file emptiness?

here a short sniplet of what i've written (which of course doesn't work):

Code:
echo "checking length of nmlfilelist"
if( $nmlfilelist == "" ) then
    echo "nmllist is empty"
    exit( 1 )
endif

this raises a syntax error, which i can retrospectively understand. how should it look like?

thx in advance,

Pagod
Reply With Quote
Remove advertisements
!!
Forum Sponsor