0

I try to write grep alias exclude log files

alias gr='grep -R --exclude=\*.{log,0,1,2,js} "$1" *'
alias gr='grep -R --exclude=\*.{log,0,1,2,js} $1 *'

Doesn't work correct

I need to make something like gr "sometext"

1 Answer 1

1

You cannot use arguments ($1) in an alias. Use a function instead.

function gr { grep -R --exclude=\*.{log,0,1,2,js} "$1" * ; }

This should work.

3
  • gr "sometext" zsh: command not found: sometext Aug 21, 2012 at 9:25
  • @ВячеславЛогинов If you are using zsh, why did you tag it with bash?
    – geirha
    Aug 21, 2012 at 22:26
  • usually zsh do same as bash, also i try this trick in bash Aug 21, 2012 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .