I am posting this info only after having confirmed the fact that there are no prior posts avialable that serves my purpose .
In my Korn Shell script file , there are two shell variables which needs to be tested within a single if statement .
Sample variables :
$var1 and $var2
The check should be :
if $var1 is NULL(empty in Unix) OR $var2 == "Y" ,
then
do logic 1
else
do logic 2
fi
The way I wrote the if-else block is ;
The problems I am facing are :
1. Even if for cases where $var1 is empty , logic 2 is executed
2. The script runs but with an error message like "argument expected"
I tested the two conditions individually , and they executed as expected , but when they are commbined with and -o operator , they yield improper result.
Thanks a ton to all you guys , your help is truly appreciated .
But what difference does the double quotes around the shell variable make ?
Why without the double quotes the IF-ELSE conditions is not matching , but using them works wonders ?
Can you please guide me on the significance of double quoting shell variables and the way Unix interprets them while comparing?
All I know about double quote usage is that it is tolerant to variable expransions while single quote considers literal values of the constituent string.
I am analyzing one of the scripts written by another person.script is having multiple if conditions and everything are nested.The code is not formatted properly.Is there any way to identify in Unix to identify begin and end of a particular if block? (6 Replies)
Fellas,
Am new to unix os/ and here the situation , I am trying to write multiple condition statement inside if but it throws me a error
here is my piece of code ,
if ] && ] && ]
then
commands
fi
error : line 15 : `
can someone please advise me how to fix it
Please use... (7 Replies)
Hello,
I have a file with below content - Example
3
6
69
139
210
345
395
418
490
492
I would like the result as - Multiple of 70 or nearest number in the file less than the multiple of 70
69
139 (5 Replies)
HI Guys,
I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
Hello Unix-Forums!
It has been a long time since my last post, but finally I've got a new question:
I know in case you can use multiple patterns by
case $var in
a|b|c|ab)
and so on.
But how would I place an OR between
if ]
then
...
if ]
then
...
I want to execute the "..." if... (3 Replies)
When I try the below if Condition with single condition its working fine.
But when I try to Club both its working . But giving wrong results.
In my case
cond1 = -f ${filename1} = true
cond2 = -f ${filename2} = true
But Cond1 & Cond2 is resulting in False ??? Please advise
... (5 Replies)
Hi All,
I am new to shell scripting.
Can any one say what is wrong in this if statement, that uses multiple conditions
if
then
***************
else
if ( -z $pcs && "$night_time_calc" > "$night_time" )
then
********************************
... (4 Replies)
Guys, Im trying to have a script that evaluates multiple conditions :
test.sh:
if
then
echo "host $1"
else
if
then
echo "host $1"
else
echo $1 not valid
exit 1
fi
when I do
./test.sh brazil1
I get: (4 Replies)
Hello,
I am having trouble with the syntax with a conditional statement in a BASH script involving multiple conditions. Any suggestions would be greatly appreciated!
if ; then
array=("${array}" "$dnNum" )
fi
i receive this error:
./testscript: ' (4 Replies)