user2786596
user2786596

Reputation: 145

How to use expr with echo and $

  #!/bin/bash

  echo "Please enter a number that can divided by 5"
  read input
  ans= 'expr $input/5'

  echo "$ans"

So i want this code to be something like this, a user will enter a number that can divided by 5 (5,10,15,20 etc etc) and then it will echo the answer, i am not sure whats wrong with my code it keeps saying "no such file or directory " for output not sure how to fix that.

Upvotes: 0

Views: 3477

Answers (1)

John C
John C

Reputation: 4396

I think the spaces were your problem...

#!/bin/bash

echo "Please enter a number that can divided by 5"
read input
ans=`expr $input / 5`

echo "$ans"

Upvotes: 3

Related Questions