This question already has an answer here:
- How to pass parameters to an alias? 3 answers
In my coding, I always do
grep -rnIi "abcabc" . --color
But, how to make an alias that can let me type only one word with my search string? Is that possible?
Pay attention to the tags on this question. This answer is the correct one given the version of
I don't believe you can do this using just an alias (at least not in the form that you've written it - see @Graeme's answer for an alternative syntax).
NOTE: I'll also mention here that @Graeme's solution though correct does not work on CentOS 5 & 6. I've confirmed this and it does in fact appear to be an issue with the version of
Aliases cannot take arguments being passed into them. They're more synonymous to a macro where they can get expanded by the shell to something else.
This can then be used like so:
Back to your question
So you can use a function in the shell instead. Functions can take arguments.
You then use it like this:
This can actually be an alias. The
The behaviour of searching the current directory by default was introduced in
So, on versions
For versions of
Assuming, of course, that there is no requirement for the