The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to compare null and space using single if condition jayakumarrt UNIX for Dummies Questions & Answers 3 05-16-2008 05:13 AM
compare null with non-null nitin Shell Programming and Scripting 8 11-04-2006 07:58 PM
Find null fields in file rahulrathod Shell Programming and Scripting 2 06-23-2006 04:17 AM
Find files which contain a null character Bab00shka UNIX for Dummies Questions & Answers 5 12-16-2005 10:41 AM
/dev/null sam71 UNIX for Dummies Questions & Answers 3 05-05-2005 09:25 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-17-2007
koti_rama koti_rama is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 50
How can find Null value in If condition

Hi,
i wrote If Conditions in my script, it's returns null and some values.
but i am unable to find when Null value getting. bec we need modification according null vales.
pls help me on this.
  #2 (permalink)  
Old 07-17-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
NULL strings would translate to a string of length zero.

You could do this to check for the NULL'ness of a string.

Code:
if [ ! -n "$VARIABLE" ] ; then
  echo "VARIABLE is empty"
fi ;
or

Code:
if [ -z "$VARIABLE" ] ; then
  echo "VARIABLE is empty"
fi ;
See man test to see the description of the flags -n and -z
  #3 (permalink)  
Old 07-17-2007
srikanthus2002's Avatar
srikanthus2002 srikanthus2002 is offline
Registered User
  
 

Join Date: Sep 2006
Location: Can u guess...!
Posts: 160
Code:
if [ "x $value" == "x """ ]
#if [ ! -n "$value" ]
then
        echo "empty"
else
        echo "Not empty"
fi
try it out..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0