I have dafined the following in .bashrc:
alias fg='find . -name $1 | xargs grep --color $2'
in order to write
fg "*.txt" " my_text "
and find all file that have extension .txt and contain " my_text " but it does not work. Why?
|
Aliases in bash do not take parameters (as already pointed out), so when you need something like that you can use bash functions (like the one provided by @l0b0). But what you are trying to achieve here, can be done in a better way by using only grep.
BTW, EDIT: in a function
|
|||||
|
|
|
|||||
|
|
|
|||||||
|
|
This works!
|
|||||||
|
fgto a function instead. – faif Mar 18 '11 at 9:39fg is a shell builtin, I recommend you chose a different name whether you implement this as an alias or (better still) a function. – Johnsyweb Mar 18 '11 at 9:53