0

I am wondering if it's possible to have a single line command that echoes a value at the end.

Example:

let N=444,M=555,O=N*M,echo "$0"
3

Sure:

N=444;M=555;echo "$(($N * $M))"

or

N=444;M=555;O="$(($N * $M))";echo $O

or

N=444;M=555;echo $N*$M | bc -l

Don't forget to run:

unset N && unset M

after your one-liner so your shell won't get polluted with useless variables.

2
  • so could it be N=444;M=555;O=N*M;echo “$O” if i wanted to declare O as the product of M & N
    – bkirklint
    Dec 10 '15 at 7:13
  • Yes, it would be N=444;M=555;O="$(($N * $M))";echo $O
    – Anubioz
    Dec 10 '15 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy