LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   not getting right output,getting error "not recognised $age" (https://www.linuxquestions.org/questions/linux-newbie-8/not-getting-right-output-getting-error-not-recognised-%24age-841386/)

namita m 10-30-2010 09:23 AM

not getting right output,getting error "not recognised $age"
 
clear
echo -n "enter ur birth year "
read byear
cyear='date | tr -s ''| cut -d "" -f 6'

age='expr $cyear - $byear'

echo "ur $age"

grail 10-30-2010 09:46 AM

Is there a reason you don't just use:
Code:

cyear=$(date +%Y)
And for the math you do not need expr either:
Code:

age=$((cyear - byear))
Of course depending on the month and day this is only an approximation.

namita m 11-01-2010 12:48 PM

thanks grail


All times are GMT -5. The time now is 02:27 PM.