In case you were wondering, to calculate the square root of a number in a shell script (bash, zsh, etc.), use bc:

bc <<< "scale=3; sqrt(7)"

Don't ask me why I needed to know this, I would like to forget.

#cli #bash

@konst why the scale?
@StephenC if you leave out the scale, the default is to drop the decimal places (not even to round)!
@konst aaah. The old sneaky truncation hidden in a function trap

@konst Since youโ€™re saying โ€œetc.โ€, I feel compelled to mention that `<<<` works in bash, but is not in POSIX and will therefore for example not work in #!/bin/sh scripts in Debian. See https://mywiki.wooledge.org/Bashism

#bashism

Bashism - Greg's Wiki

@scy thanks I was wondering about which shells support <<< herestrings. Looks like zsh, bash and ksh will work though.