maric92
maric92

Reputation: 23

How to use variables in shell?

Having a simple script like this, which should convert minutes to seconds

#!bin/bash
echo 'input_minutes'
read x
time="expr $x '*' 60"
echo $time

When run after entering a number (5), it outputs an expression "expr $x '*' 60" instead of a product(300). What could be the reason?

Upvotes: 0

Views: 25

Answers (1)

StefanR
StefanR

Reputation: 676

You didn't execute the expression, instead you created a string. Try it like this:

time=$(expr $x '*' 60)

Upvotes: 1

Related Questions