fork download
  1. #!/bin/bash
  2.  
  3. # Prompt user for input
  4. echo "Enter your name: "
  5. read NAME
  6. echo "You entered: $NAME"
  7.  
  8. echo "Enter your birth year: "
  9. read BIRTH_YEAR
  10. echo "You entered: $BIRTH_YEAR"
  11.  
  12. echo "Enter the current year: "
  13. read CURRENT_YEAR
  14. echo "You entered: $CURRENT_YEAR"
  15.  
  16. # Calculate age
  17. AGE=$((CURRENT_YEAR - BIRTH_YEAR))
  18.  
  19. # Display the result
  20. echo "I am $AGE years old."
Success #stdin #stdout 0.01s 5268KB
stdin
ten
2004
2025
stdout
Enter your name: 
You entered: ten
Enter your birth year: 
You entered: 2004
Enter the current year: 
You entered: 2025
I am 21 years old.