Hi,
I am new to UNIX. I wonder how to set value to variable in UNIX..
my code:
if [ -f /home/batch/sample.txt ]; then EXIST=$a ; else EXIST=$b ; fi'
echo $EXIST
the value of EXIST is empty...
Thanks 
Hi,
I am new to UNIX. I wonder how to set value to variable in UNIX..
my code:
if [ -f /home/batch/sample.txt ]; then EXIST=$a ; else EXIST=$b ; fi'
echo $EXIST
the value of EXIST is empty...
Thanks 
Initially assign some values to variable "a" and "b" as
a=10 <sample_data>
b=11 <sample_data> Then check
Is $a and/or $b defined ?
if I use this code, it works fine.
ssh batch@192.168.3.222 'if [ -f /home/batch/sample.txt ]; then echo "exist" ; else echo "not exist" ; fi'
it will print out "Exist"
But if I use this code, it display "0".
a=0
ssh batch@192.168.3.222 'if [ -f /home/batch/sample.txt ]; then a=1 ; else a=2 ; fi'
echo $a
It seems that the value is not assigned to the variable inside the if-else statement.
yes, because you ran it to a different machine
a=`ssh batch@192.168.3.222 'if [ -f /home/batch/sample.txt ]; then echo 1 ; else echo 2 ; fi'`
echo $a
Hi ryandegreat25,
Thanks.. it works now... ![]()