Add this somewhere where it would be loaded into your bash environment: (~/.bashrc is one option) (It is a bad idea and won't work for division without spaces, see man page excerpt for why) (The exit is needed only for some non-GAWK AWK versions)
command_not_found_handle() {
# AWK version, security risk
awk "BEGIN { print $*; exit; }" # Use AWK as a calculator
# If you want to keep what you did previously:
# BC version, possibly less of a security risk, but an extra process is involved
# echo "$*" | bc -l | awk '{printf "%f\n", $0}'
echo "$0: $1: command not found" 1>&2 # Send error to STDERR
exit 127 # Keep same exit status as otherwise
}
From the bash man page: (This functions gets invoked when bash runs out of other options)
If the name is neither a shell function nor a builtin, and contains no
slashes, bash searches each element of the PATH for a directory con-
taining an executable file by that name. Bash uses a hash table to
remember the full pathnames of executable files (see hash under SHELL
BUILTIN COMMANDS below). A full search of the directories in PATH is
performed only if the command is not found in the hash table. If the
search is unsuccessful, the shell searches for a defined shell function
named command_not_found_handle. If that function exists, it is invoked
with the original command and the original command's arguments as its
arguments, and the function's exit status becomes the exit status of
the shell. If that function is not defined, the shell prints an error
message and returns an exit status of 127.
echo $(( (450+12) /100))bc?