Operating System - HP-UX
1831677 Members
2122 Online
110029 Solutions
New Discussion

Test the result coming from a ksh function

 
Leo The Cat
Regular Advisor

Test the result coming from a ksh function

Hi Guys


Example

function GetFileSize {
XX=$(du -m /su01/odb_Local_OracleCRSlogMngt.ksh | awk '{print $1}')
return $XX
}

...
...

X=$(GetFileSize $i)
if (( $X <= 100 )) ; then
echo "<= 100"
else
echo ">100"
fi


I have a file where I'm sure that size is 500 MB and it never comes as > 100 !

Where is my mistake ?

Bests regards
Den


3 REPLIES 3
Viktor Balogh
Honored Contributor

Re: Test the result coming from a ksh function

I' not sure which shell are you using, but in ksh I would implement that if branch this way:

if [ "$X" -le "100" ]; then
echo "<= 100"
else
echo ">100"
fi

where "-le" stands for "lesser than or equal", see "man test"
****
Unix operates with beer.
Leo The Cat
Regular Advisor

Re: Test the result coming from a ksh function

;-) My mistake

function GetFileSize {
XX=$(du -m /su01/odb_Local_OracleCRSlogMngt.ksh | awk '{print $1}')
return $XX
}

is wrong

function GetFileSize {
XX=$(du -m $1 | awk '{print $1}')
return $XX
}


Of course, I was scanning always the same files.

Sorry Guys
Den
Leo The Cat
Regular Advisor

Re: Test the result coming from a ksh function

Myself. ;-)