Grep Alias


 
Thread Tools Search this Thread
Operating Systems Linux Grep Alias
# 1  
Old 08-07-2013
Blade Grep Alias

I would like to create an alias on my 'grep' command on Linux.

Generally when I use 'grep', I do as follows:

Code:
$ 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?
# 2  
Old 08-08-2013
Could I suggest that you use the functions of the shell to work with patterns. Something like this would sort your issue:-
Code:
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:-
Code:
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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

2. OS X (Apple)

Having trouble creating an alias for grep

Hi, I'm using Mac 10.9.1. I would like to create an alias for grep so that it won't print out messages like "grep: /Users/davea/workspace/myproject/subdir/: Is a directory" all the time. So in my terminal, I opened ~/.profile and entered alias grep='grep -s' However, when I close and... (5 Replies)
Discussion started by: laredotornado
5 Replies

3. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

4. UNIX for Dummies Questions & Answers

Alias help

I can get the nth line of a file using sed -n 'np' file however all I want to type is "line n file" so I am trying to use alias alias line='sed -n \'&\'' but its not working, how can I make this work Thanks (2 Replies)
Discussion started by: chrisjones
2 Replies

5. UNIX for Dummies Questions & Answers

using alias

I need to login to one server and then switch the user and set a number alias. But i cant modify the .profile file. I have one script avi1.sh $ more avi.sh sudo su - bil sh avi1.sh and in home directory of bil i have avi1.sh that says $ more avi1.sh alias l='ls -ltr' alias b='cd... (7 Replies)
Discussion started by: blackeyed
7 Replies

6. UNIX for Dummies Questions & Answers

Help with Alias

Hi, I have a software package consisting of a group of BASH shell scripts. There is a master script which calls a series of subscripts. To run the software users must open the master script, modify and save it, and then run it. To open the script you can either double-click on it, or you can... (2 Replies)
Discussion started by: msb65
2 Replies

7. Shell Programming and Scripting

Alias

how implement functionality alias in the same way as in csh? (use Bourne type sh or bash) (3 Replies)
Discussion started by: sunhata
3 Replies

8. HP-UX

alias help

i want to use short cut alias command but its not happening can any on help (4 Replies)
Discussion started by: shafique
4 Replies

9. UNIX for Advanced & Expert Users

using alias...

hi.. i want to make an alias in unix, for using it to change of directory by example: if i am in /dtmp/inp/aux and i want to go to /sybase/bd, i want to make an alias named "bd", to go directally to /sybase/bd (alias bd="cd /sybase/bd") i create it, but when i turn off the conection... (2 Replies)
Discussion started by: DebianJ
2 Replies
Login or Register to Ask a Question