Varibale to NULL or ZERO


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Varibale to NULL or ZERO
# 1  
Old 09-06-2006
Varibale to NULL or ZERO

I have a variable called V_param1 and does it have some value.

I want to check this varibale is NULL or Zero then exit else do

How to incorported this in Script. any input
# 2  
Old 09-06-2006
MySQL

try this snippet :

if [ -z $w ]; then
echo "W is null"
else
echo "W has some value"
fi
# 3  
Old 09-06-2006
we can check with
[[ $d -eq 0 ]] && exit 1

To check run the below script
Code:
d=
echo $d
[[ $d -eq 0 ]] && echo dell

and
Code:
d=
echo "d is $d"
[[ $d -eq 1 ]] && echo "hell $d"

[[ -z $Varname ]] is also correct but it will fail if varname has value 0.

Last edited by Dhruva; 09-06-2006 at 08:21 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass IF condition via shell varibale in awk?

Hello, I have one query regarding passing IF condition shell variable inside awk. Here is the case- File content of keydefn.exp 201~2~LM Limit 02-current value~Limit 02 ~Limit02~Current~Value ~N~Y~S~0~9999999 201~3~LM Limit 03-current value~Limit... (2 Replies)
Discussion started by: anillambait
2 Replies

2. UNIX for Dummies Questions & Answers

set varibale to be output of a command

Hi there! :) How to set varibale to be output of a command in csh. I was using set i="date+'%y%m%d'" but the output is date+'%y%m%d' and without quites and with a single quote the output is the same :wall: :eek: Thanks in advance (2 Replies)
Discussion started by: FUTURE_EINSTEIN
2 Replies

3. Shell Programming and Scripting

Redirecting standard out to /dev/null goes to file "/dev/null" instead

I apologize if this question has been answered else where or is too elementary. I ran across a KSH script (long unimportant story) that does this: if ; then CAS_SRC_LOG="/var/log/cas_src.log 2>&1" else CAS_SRC_LOG="/dev/null 2>&1" fithen does this: /usr/bin/echo "heartbeat:... (5 Replies)
Discussion started by: jbmorrisonjr
5 Replies

4. UNIX for Dummies Questions & Answers

/dev/null 2>&1 Versus /dev/null 2>1

How are these two different? They both prevent output and error from being displayed. I don't see the use of the "&" echo "hello" > /dev/null 2>&1 echo "hello" > /dev/null 2>1 (3 Replies)
Discussion started by: glev2005
3 Replies

5. Shell Programming and Scripting

Insert string 'NULL' where there is a null value

I have an input file having 7 fields delimited by , eg : 1,ABC,hg,1,2,34,3 2,hj,YU,2,3,4, 3,JU,kl,4,5,7, 4,JK,KJ,3,56,4,5 The seventh field here in some lines is empty, whereas the other lines there is a value. How do I insert string NULL at this location (7th loc) for these lines where... (8 Replies)
Discussion started by: zilch
8 Replies

6. Shell Programming and Scripting

How to use a varibale in sed

i wanna insert a row in a file. I m using this command to insert a row in the 13th line. sed '13i\ NewRow' MyFile > temp.txt mv temp.txt to MyFile this works fine. now i wanna get the line no using grep into a variable and then use tht variable to insert a new row.. how to do this wid... (8 Replies)
Discussion started by: St.Fartatric
8 Replies

7. Shell Programming and Scripting

passing of a varibale to subshell

Hi All, I need some info. Could you please tell me how to use the variable of a parent shell in the subshell. Also can we modify the variable in the subshell ? If yes, will the modified variable visible in the parent shell I am using two prg. a.sh #!/usr/bin/ksh temp_var="abhishek"... (3 Replies)
Discussion started by: AbhishekG
3 Replies

8. Shell Programming and Scripting

compare null with non-null

I've got a very peculiar situation. I'm trying to find out if we can compare null fields with non-null. I've output csv files from SQL and Oracle. I need to compare each field from the files, and then find out any differences. The files usualy have over 500 fields, and send the resule to DBA.... (8 Replies)
Discussion started by: nitin
8 Replies

9. Shell Programming and Scripting

passing result of query to a varibale in ksh script

Hi, I have a scenario where in i have to extarct max of one column and pass it to a variable. i have tried to export the result as .dat file and read from that file.But my database is mainframe and it is not permitting me to export in .dat file.I have tried using .ixf file but reading from... (2 Replies)
Discussion started by: ammu
2 Replies

10. UNIX for Advanced & Expert Users

Null Value

Hello All, I have a file of the format **** 123 abc ABC 456 bcd BCD 789 def 112 ghi GHI 223 jkl 344 mno MNO **** I am trying to extract the lines that have no values in the third field (in this case, this would be 789 def 223 jkl Can anyone please help??... (1 Reply)
Discussion started by: Khoomfire
1 Replies
Login or Register to Ask a Question