[Solved] How to remove listing of current user cmd from ps -ef listing?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] How to remove listing of current user cmd from ps -ef listing?
# 1  
Old 02-06-2013
[Solved] How to remove listing of current user cmd from ps -ef listing?

Hi All,


Could you please help to resolve my following issues:

Problem Description:

Suppose my user name is "MI90".
i.e. $USER = MI90

when i run below command, i get all the processes running on the system containing name MQ.

ps -ef | grep MQ

But sometimes it lists "grep MQ" cmd also in its output, which is nothing but the above cmd which i executed to check all the running processes of system.
& sometimes not.

NEED:

My need is that it should always avoid listing "grep MQ", which has been started just now by the current user i.e. MI90

Examples:

when i run $ ps -ef | gre MQ

i got :

MI90 36241614 36110452 0 05:41:31 pts/2 0:00 grep MQ
tibco 38535330 1 0 02:05:18 - 0:11 /appl/tibco/adapter/admqs/6 .2/bin/admqs --pid --run --propFile /appl/tibco/tra/domain/PR/application/MQAdap ter/MQAdapter-ABNAMROMQAdapter.tra --innerProcess
tibco 38797444 1 1 02:05:18 - 0:11 /appl/tibco/adapter/admqs/6 .2/bin/admqs --pid --run --propFile /appl/tibco/tra/domain/PR/application/MQAdap terNew/MQAdapterNew-ABNAMROMQAdapterNew.tra --innerProcess


but i always need only below:

tibco 38535330 1 0 02:05:18 - 0:11 /appl/tibco/adapter/admqs/6 .2/bin/admqs --pid --run --propFile /appl/tibco/tra/domain/PR/application/MQAdap ter/MQAdapter-ABNAMROMQAdapter.tra --innerProcess
tibco 38797444 1 1 02:05:18 - 0:11 /appl/tibco/adapter/admqs/6 .2/bin/admqs --pid --run --propFile /appl/tibco/tra/domain/PR/application/MQAdap terNew/MQAdapterNew-ABNAMROMQAdapterNew.tra --innerProcess


So please help me in getting such o/p....

Thanks in advance!
Regards,
KD
# 2  
Old 02-06-2013
Code:
ps -ef | grep MQ | grep -v grep

From grep manual page:
Code:
-v   All lines but those matching are printed.

This User Gave Thanks to Yoda For This Post:
# 3  
Old 02-06-2013
Hi Bipin,

Thanks a lot, it exactly solved my problem.
once again thank youSmilie

Regards,
KD
# 4  
Old 02-06-2013
Try
Code:
ps -ef | grep [M]Q

# 5  
Old 02-08-2013
RedHat

Hi Rudic,

Please let me know what does [M] implies.
how does it filter?
# 6  
Old 02-08-2013
It does not filter at all, but modifies the command line of the grep command so the pattern grep searches for will not be matched. "[...]" is a regex matching exactly one char from the set supplied. In your case, there's only "M" to match, which is used by grep.
# 7  
Old 02-11-2013
An attempt to shed more light on why RudiC's method is preferred.

Less overhead as a pipeline does not need to be created. grep is only called once.

The pattern [M]Q matches a string starting with a capital M followed by a Q. It does not match itself (as would be shown in a ps -ef) as the grep pattern starts with a '[', not an M.

Last edited by gary_w; 02-11-2013 at 11:32 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Listing multiple files in windows cmd

i have multiple files like how to do list files from new_30 to new_50 i have tried this command but it wont work dir new*{30-50}.txt my exact requirement is to get line count of these files the command which work is FOR %i IN (new*.txt) DO find %i /c /v "" but at the... (1 Reply)
Discussion started by: sagar_1986
1 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Listing files starting with p or f and with the exact length of 3 characters

Hello, I need some help. How can I list files starting with p or f and with the exact length of 3 characters? (2 Replies)
Discussion started by: airbebe
2 Replies

3. UNIX for Dummies Questions & Answers

Listing based on User and Date

listing based on user. I have files in some folder that come from many user -rwxrwxr-x 1 ratih pbank 4827112 Jun 8 08:37 S92TA-8.sgy -rwxrwxr-x 1 ratih pbank 4724568 Jun 8 08:37 S92TA-6.sgy -rwxrwxr-x 1 ratih pbank 4929656 Jun 8 08:37 S92TA-19.sgy -rwxrwxr-x 1 ratih ... (4 Replies)
Discussion started by: muhnandap
4 Replies

4. UNIX for Dummies Questions & Answers

[Solved] Problem with listing my files

Hello, In my directory i have got a list of files like below unix1a.csv unix1b.csv unix1c.csv unix1d.csv unix1y.csv I have done ls -lrt unix1.csv, how can i get my unix1y.csv also get listed along with this.. (5 Replies)
Discussion started by: sathyaonnuix
5 Replies

5. UNIX for Dummies Questions & Answers

listing home dir of anothe user

Hi I am trying to display the home directory of another user. I dont have the permissions to change into their directory and wonder is it possible to display their directory eg I cant change directory to john but I am trying to display something like /home/John. If anyone can help I would... (3 Replies)
Discussion started by: mmg2711
3 Replies

6. UNIX for Dummies Questions & Answers

Listing only directories in the current working directory using the "ls" command

Hello All, I am trying to list only directories in my current directory using the command "ls -d". But the output only contains the default directory "." and doesn't list the rest of the directories in the working directory. Can anyone explain why this is happening (2 Replies)
Discussion started by: igandu
2 Replies

7. UNIX for Dummies Questions & Answers

listing files that does not belong to current date

How do we list all the file names in a directory that does not belong to current date. (3 Replies)
Discussion started by: esh.mohan
3 Replies

8. Shell Programming and Scripting

listing files that do not belong to current date

How do we list all the file names in a directory that does not belong to current date. (1 Reply)
Discussion started by: esh.mohan
1 Replies

9. UNIX for Dummies Questions & Answers

Find files older than 5 days and remove tem after listing

need help with this ... Find files older than 5 days and remove tem after listing list "test" file older than 5 days and then remove them (1 Reply)
Discussion started by: ypatel6871
1 Replies

10. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies
Login or Register to Ask a Question