 This video is part of a series. Be sure to check out the full playlist and the link in the description of this video I hope you're enjoying these shell script tutorials and we're looking at some shell commands today So they were gonna be looking at the gang the PID the process ID of a running process a running program You this is useful to in many ways to kill a process But if you need to get a process ID, there's two different ways the way that I Normally do it, which is not the best way I think a lot of people do this is they use the ps command so if I if I ps It will give me a list of running programs But that's just for this current session if I do AUX is usually the way I run it which gives me for all users and all that stuff and then of course I can Grip that if I want to say let's say my shell is z shell So I probably have a few of those running right there. Let's clear the screen run that again So this is all the z shell or at least all the commands Running with the word z shell there, which is not necessarily all z shell Processes for example, I'm getting the grip command that I just ran because it has the word z shell So that's not the best not the cleanest way to do it Well, you can also use the ps command if you look in the man page Dash capital Z is case sensitive and I type z sh. It's going to give us a nice little clean These are you know Processes here's the IDs the TTY for them and Time But CMD is the command so that's nice clean We're not going to have to worry about that grip command blah blah blah and that's fine And if we want to there's probably a ps command to get just the process ID But I would pipe this into just doing what I know dollar sign one meaning the first column And that kind of works we got the process IDs here, but we also have this PID which we could remove with awkward grip But blah blah blah, but we're piping again Unnecessarily we don't need to do that again. There might be a ps command to get this process ID Look through the man page, but I'm gonna show you two other ways that actually work a little bit better One and this is the simplest remember is PID of so it will give you the PID of and I can say Z shell here and it just gives us All the process IDs for the Z shell processes another one is P. Grap And I said to say P. Grap Z shell and it basically gives you the same output. That's certainly the same or it looks like reversed One gives you in a column format one gives you you know with spaces either or you can loop through those And kill them all if you want although the kill all command It would also work But you can go through those and if you need the PID of a process Whether it's running one or more those are probably the two cleanest ways I know of is PID of and P. Grap So check those out and I know a lot of there's a lot of different Variations of grep out there e grep p grep blah blah blah and a lot of those processes depending on the version of grep You have most process a lot of those functions depending on what version of grep you have might be built into Regular grep already and in fact that might be an alias for a regular grep. I don't even look into that I just know P grep Z shell but actually PID of is the one that I've started using recently because it's just He's a remember if I just need the PID obviously Doing my original command if I'm Let's see PSAUX grep Z shell Gives me a little more information if I'm looking for a particular one I go and then copy and paste but if I just want to script it out to grab the PID of all the processes or You know, maybe find the latest one. I can you use one of those other commands and it's a bit cleaner one of the most powerful things in a in a shell is the ability to pipe the output of one command into another command But at the same time you should limit doing that as much as you can because you're running processes You don't necessarily need if one command can do it. So I do. Thank you for watching As always be sure to check out my website films by Chris comm that's Chris the K There's linking description there. You can search through all my scripts my notes under the Scripts section. It's either called scripts or notes on my website. I need to check I think it's called scripts. It'll bring you to my notes, which is basically Anytime I create a script or write notes for myself I put them in paste bin and paste bin is great, but there's no right clean way to search through it So every day I have a cron job on my server that pulls down the latest Posts that I've done puts them into a database and then this interface on my website will search through it in a very sloppy way I actually have every script load into the HTML of the page And then I use JavaScript to sort through that and really I should be sorting it with the database Not loading everything the page because it makes a little slow. It's not that slow on a desktop computer on a phone right now There's almost 600 scripts in there and again it searches through all of the words on that and your device doing that So on an older phone it might take three to five seconds for it to filter through everything So I really need to rewrite that to do everything on the server side Just as a you know, just that's but I'm actually holding off on that because I'm actually starting to use Gist more so I'm posting all my scripts to paste bin and gist So I'll probably look into seeing if there's an API for gist And so using that said because that definitely is a little bit nicer because it does revisions and stuff like that If you've never used it if you've used get it's like get but for you know Projects there's one or two files rather than a full-blown project. Anyway, I'm babbling now But looking through that I have lots of great notes there I put it there I built for myself, but I'm sharing it with you guys. I go there all the time You know, I know I know how to do something about I'm gonna do it I can type in the keywords and it will narrow down my my scripts And I can look and see how to do something about having to Google it and then read through articles It's just that my notes are very short or code there. Check it out Also, check out the support section on my page You can go to patreon.com for such me looks 1000 or my PayPal account again all at films like Chris calm Go ahead check that out. Support is great. Be sure to like share subscribe comment all that fun stuff I appreciate you watching. I also appreciate you sharing so other people can watch too be considerate of other people Let them know how great my videos are as always. I hope that you have a great day