Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"

share|improve this question

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.

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.