I would like to create an alias on my 'grep' command on Linux.
Generally when I use 'grep', I do as follows:
$ ps -ef | grep -i ntp | grep -v grep
My question is how can I simply run the 'grep' command as shown above and it also include the -i / -v switches as well w/o me having to enter them in manually every time?
Could I suggest that you use the functions of the shell to work with patterns. Something like this would sort your issue:-
ps -ef | grep -i nt[p]
The string actually searched for is ntp
but your process doesn't look like that, so it is excluded.
The expansion rules will define the [p]
bit as a range of characters of, um, well the letter p only. It's a one character range as opposed to:-
ps -ef | grep nt[a-z]
which will give you all processes containing any of the the strings nta, ntb, ntc, ntd, nte......
I hope that this helps,
Robin
Liverpool/Blackburn
UK