![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Checking the Empty line in csv file | sollins | Shell Programming and Scripting | 4 | 05-15-2008 04:48 AM |
| Checking for the presence of a string within another string | hidnana | Shell Programming and Scripting | 1 | 03-20-2008 02:38 AM |
| Check for empty string | rahman_riyaz | Shell Programming and Scripting | 12 | 01-23-2008 11:13 PM |
| How to check for null or empty string | doer | Shell Programming and Scripting | 5 | 07-23-2007 10:31 PM |
| Checking if string contains integer | haz | Shell Programming and Scripting | 7 | 09-10-2006 11:51 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
|||
|
Your code snippet works for me. If you wish to use some other means of testing for an empty string you can always using the test utility. Man test(1) for more information.
Code:
set nmlfilelist [ -z $nmlfilelist ] && echo "nmllist is empty"; exit (1) |