Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: killing processes thru' C programs Message-ID: <1991May1.042929.20381@athena.mit.edu> Date: 1 May 91 04:29:29 GMT References: <1991Apr24.144240.3322@uoft02.utoledo.edu> <1991Apr29.054531.4981@athena.mit.edu> <878@systech.bjorn.COM> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 24 In article <878@systech.bjorn.COM>, dan@systech.bjorn.COM (Dan Gill) writes: |> if you use ps uxc | grep name | awk '{print $2}' the only thing displayed |> is the pid of the processes name. You should be careful for if you used |> vi as the name, there could be some unhappy campers in your KOA. There are two problems with what you have suggested. First of all, there's no reason to use two processes, when awk has regular expression capabilities. Change what you said to: ps uxc | awk '/name/ {print $2}' Second, as someone else has pointed out in another message, if you use 'ps uxc', then shell scripts are listed as "sh" instead of as the name of the script, which means you can't kill scripts using this method. Given that I need to do that at times, it makes more sense to use what I suggested (i.e. "ps ux" and search with awk '/name/ && !/awk/ {print $2}') than it does to use "ps uxc". -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710