LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-30-2010, 09:23 AM   #1
namita m
LQ Newbie
 
Registered: Oct 2010
Posts: 3

Rep: Reputation: 0
Post 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"

Last edited by namita m; 10-30-2010 at 09:26 AM. Reason: question is how to calculate age in years,i m getting an error msg that 4not recognised age,and pls tell me how to write scri
 
Old 10-30-2010, 09:46 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,505

Rep: Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890Reputation: 2890
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.
 
1 members found this post helpful.
Old 11-01-2010, 12:48 PM   #3
namita m
LQ Newbie
 
Registered: Oct 2010
Posts: 3

Original Poster
Rep: Reputation: 0
thanks grail
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cifs "mount error 5 = Input/output error" but smbfs works! humbletech99 Linux - Networking 27 06-01-2017 05:59 AM
[SOLVED] MM Beta: "Error 5: Input/Output Error" when installing from a live USB Kenny_Strawn Ubuntu 17 09-07-2010 08:56 PM
square brackets in output of "ps aux" not matching output of "ps -ejH" alirezan1 Linux - Newbie 14 07-14-2010 04:17 AM
"failed to execute child process" "Input/output error" fl.bratu Fedora 4 12-15-2008 04:03 AM
Java does "age" or "Age" matter when declaring an Int?? Laptop2250 Programming 3 10-13-2003 12:34 PM


All times are GMT -5. The time now is 12:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration