shell script to kill processes running on port number
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.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So first "lsof -i :80" will be run. Its output will be piped to tail -n +2 which cuts off the first line, which we don't need. The rest will be piped to sed which in this case will truncate all spaces/tabs to one space only for easier parsing. This text is then piped to cut which in this case will print only the second column delimited by a single space (which we created using sed a step earlier). The output will then be all the PIDs without the rest.
Since all this happens within backticks (`) the output from cut will then be inserted in the first command which will then look like this (for example):
man lsof
man sed
man tail
man cut
google linux pipe
Then if you have a question I am sure people will help further
*sigh* there goes the oh-so-helpful linux community down the drain...
Posts like yours are the reason why I often hear statements along these lines:
The Linux community isn't helpful at all!
All they tell you is to use google! I can tell that myself.
And others like that. Please, if you don't have anything productive to say, just shut the fuck up, thanks.
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606
Rep:
not meant to be offensive. Just see my other 500 posts.
Was going to help if question was clearer
Also missed your answer when I posted
By posting I registered on that thread
Do not be so assuming, and mind your language
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606
Rep:
Listen, I have jsut made an appology, you could just please do the same.
No need to be sarcky ok?
If you had checked my posts to see what kind of help I give, you
would not have posted what you just did.
>>Can you also explain this command??
Was not sure what the guy did not understand and where he needed help
Also I explained that I did not see your post. I know I am daft
Sorry for it all, but I really get sick at "use google to find out" posts because I keep seeing them literally everywhere I go. So called "help" channels on IRC, mailing lists, newsgroups, everywhere.
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606
Rep:
Thanks. I know, sorry here as well. I was wondering when I was posting about my googling advice being "sane", but I had posted quite a few hints/help to people already, and was running out of steam.
Sometimes script questions are from students, so I tend to want to know what is unclear or expect some homework first.
plz is a good indication of studenthood / younger people. I do not say we have one here, though.
At the same time you had given a great one liner answer
for a *not* such a simple question (IMHO) where one would have expected whoever posted the question to be able to understand / search to understand, not fishing for information / help in that way
Anyhow, I am waffling. This is on top of what I wrote before.
I know googling is not always a suitable message.
Maybe you are kinder, and I am more cynical ?
Nevermind, this is all settled. You know where I come from, and I understand your googlite frustration with non helpful comments
So first "lsof -i :80" will be run. Its output will be piped to tail -n +2 which cuts off the first line, which we don't need. The rest will be piped to sed which in this case will truncate all spaces/tabs to one space only for easier parsing. This text is then piped to cut which in this case will print only the second column delimited by a single space (which we created using sed a step earlier). The output will then be all the PIDs without the rest.
Since all this happens within backticks (`) the output from cut will then be inserted in the first command which will then look like this (for example):
Code:
kill 12435 8923 21349
Greetings,
Benjamin.
Wow! Now that is a truely helpful post. I've been looking to do something similar to this but was kinda stumped... this detailed breakdown made a little light in my head go BING!... and saved me potentially hours of time searching Google and man pages.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.