Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop zsh from expanding * (asterisk) in command line?

Tags:

zsh

I recently switched to zsh. When I was using bash, I used to use echo 2*3 |bc as a powerful and convenient calculator but in zsh the first part of the command result in error message:

$ echo 2*3
zsh: no matches found: 2*3

I know I can avoid the expansion by adding quote to the string 2*3 but is it possible to bring this feature from bash (not expanding asterisk in command argument)?

UPDATE:

In the meaning while I found bc <<< 2*3 won't trigger the expansion, weird :-(

like image 703
yegle Avatar asked Oct 02 '22 17:10

yegle


1 Answers

You can do:

noglob echo 2*3 | bc

And then create an alias around this:

calc()
{
   echo $* | bc
}
alias calc='noglob calc'
like image 157
t9mike Avatar answered Oct 13 '22 09:10

t9mike