String manipulation for PID


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting String manipulation for PID
# 1  
Old 07-22-2009
String manipulation for PID

Hi, I'm having trouble figuring out something for a script I'm writing. Where I work, we have 3 process that run a device, and they occasionally need to be killed. Everyone is doing this manually, looking up the PIDs one at a time and then typing the kill statements and PIDs manually. I'd like to take away the potential for user error there, and I'm setting up a script to do that. So what I've got is basically :

ps -awx | fgrep "proc_one
proc_two
proc_three"


and this gives me a list of 4 processes -- the 3 I want to kill and the fgrep process also (shows up something like fgrep?proc_one?proc_two?proc_three?). what I need to do is pull the PIDs from the 3 that I want to kill but not the fgrep one. I'm not sure what length the PIDs are going to be, and I'm not any good with awk or sed anyway. can anyone help me out with this one?

Thanks
# 2  
Old 07-22-2009
Look for pgrep and pkill manual
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String manipulation

Hi , I am getting a string like aaa,bbb,sdsdad,sdfsdf,sdfsdfdsf,rtyrtyr,45654654,ddfdfdfgdfg,dfgdfgdg........... Now what I need is to format it. So after each nth comma I need one newline. So the above will look like when n=3 aaa,bbb,sdsdad, sdfsdf,sdfsdfdsf,rtyrtyr,... (4 Replies)
Discussion started by: Anupam_Halder
4 Replies

2. Shell Programming and Scripting

Deleting part of a string : string manipulation

i have something like this... echo "teCertificateId" | awk -F'Id' '{ print $1 }' | awk -F'te' '{ print $2 }' Certifica the awk should remove 'te' only if it is present at the start of the string.. anywhere else it should ignore it. expected output is Certificate (7 Replies)
Discussion started by: vivek d r
7 Replies

3. Shell Programming and Scripting

string manipulation

Hi, I have the followoing details in one file: opt/tra/domain/test/new/filename1 training/ear/help I need to manipulate the string in the following manner: filename1= opt/tra/domain/test/new/filename1 help=training/ear/help last string is the name and equal sign and then... (2 Replies)
Discussion started by: ckchelladurai
2 Replies

4. Homework & Coursework Questions

String Manipulation

Write a shell program to display the position of the right - most character in a given input string. Example : Input : RAHUL Output : L is in the 5th position also tell me how to count length of string and how to find the position of specific character in left most side. Homework... (0 Replies)
Discussion started by: shashwat2691
0 Replies

5. Shell Programming and Scripting

String Manipulation

Write a shell program to display the position of the right - most character in a given input string. Example : Input : RAHUL Output : L is in the 5th position also tell me how to count length of string and how to find the position of specific character in left most side. (1 Reply)
Discussion started by: shashwat2691
1 Replies

6. Shell Programming and Scripting

String Manipulation

Hi, I have a file in the following format 123|shanwer|15DEC2010|bgbh|okok|16JAN3000|okok| I want the following to be in following format 123|shanwer|12\15\2010|bgbh|okok|01\16\3000|okok| SED/PERL/AWK Gurus could you please help me with this? Thanks Shankar (8 Replies)
Discussion started by: Shan2210
8 Replies

7. Shell Programming and Scripting

string manipulation

if I have two string variable, how do I add one to anther. like a= "a" b="b" c=$a+$b but that doesn't work. Is there anyway to solve it.http://www.qtl.co.il/img/copy.pnghttp://www.google.com/favicon.icohttp://www.babylon.com/favicon.icohttp://www.morfix.com/favicon.ico (2 Replies)
Discussion started by: programAngel
2 Replies

8. Shell Programming and Scripting

String manipulation

Hi, I have the string like this ". Start : 06:53:11 - MON JUL 05, 2010" I need to print the part "06:53:11 - MON JUL 05, 2010" How i can do this? Thanks, Lenova (2 Replies)
Discussion started by: lenova2010
2 Replies

9. UNIX for Dummies Questions & Answers

String manipulation

I am doing some training for a job I have just got and there is an exercise I am stuck with. I am not posting to ask a question about logic, just a trivial help with string manipulation. I would appreciate if somebody could at least give me a hint on how to do it. Basically, the intelligent part... (8 Replies)
Discussion started by: Dantastik
8 Replies

10. Shell Programming and Scripting

string manipulation

Hello, I have a korn shell string variable str1 = "A,B,Z" I would like to create another korn shell string variable str2 = "letter = 'A' or letter = 'B' or letter = 'Z' " Please help! Thanks in advance an UNIX newbie! (13 Replies)
Discussion started by: hai1973
13 Replies
Login or Register to Ask a Question