Pass output of one command as input to another on bash
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Pass output of one command as input to another on bash
Hello all,
I have a script that starts ifstat process everytime that script is run. I want to kill all the ifstat processes running.
I know I can get the process ids by pidof command. I want to pass the output of this command to kill so that all the processes are killed.
Is there anyway I can do this?
Like
pidof ifstat. I get some pids then I pass these pids to kill.
I need to do this on bash first and then if this works for me I will use it in script for ifstat is running unnecessarily.
You ca do this
pidof <program_you_want_to_kill>|xargs kill
As usual you can know more with man <command> or info <command>.
I must admits that the output of "man bash" may be difficult to swallow at once ... So you will find guides you need at The Linux Documentation Projects.
To begin with I would suggest reading "Introduction to Linux - A Hands on Guide" from Machtelt Garrels.
Last edited by Didier Spaier; 01-08-2009 at 01:19 AM.
Reason: Typo
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.