Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.