parse and format IP:port currently in listen state without net tools

cat /proc/net/tcp | grep " 0A " | sed 's/^[^:]*: \(..\)\(..\)\(..\)\(..\):\(....\).*/echo $((0x\4)).$((0x\3)).$((0x\2)).$((0x\1)):$((0x\5))/g' | bash
Useful for containers and environments where you need to know if a port is currently in listen mode but you have not easy way or privileges to install net-tools like netstat or ss. "0A" is the code for listen state. The IP hex is reverse order and all in hex format.
Sample Output
0.0.0.0:111
10.174.109.1:53
127.0.0.53:53
0.0.0.0:22
127.0.0.1:631
0.0.0.0:8000

2
2020-05-23 12:36:21

What Others Think

Thankyou for the information. [url=https://travelwels.com/]https://travelwels.com/[/url] Travelling gives you the opportunity to step away from the daily grind. The new events and experiences help rewire your brain, hence boosting your mood and self-confidence. For travelling or exploring the world please go through.
TRAVELWELS · 5 weeks and 5 days ago
Thankyou for the information. https://travelwels.com/ Travelling gives you the opportunity to step away from the daily grind. The new events and experiences help rewire your brain, hence boosting your mood and self-confidence. For travelling or exploring the world please go through.
TRAVELWELS · 5 weeks and 5 days ago
Tryhttp://empirepokerschool.com/">poker training ! here you will learn not only the right, but the secrets of the masters, betting strategies, table etiquette! I promise you, you won’t regret it!
Foraes · 5 weeks and 3 days ago
Thanks for sharing this wonderful information with me.
Uned1983 · 5 weeks and 2 days ago
Hello Mate - This is amazing piece of work and give me informative insights about subject matter. I would love to read more about your work to enhance my knowledge. Further, to get best Carter's Coupon Codes , please visit out website www.uttercoupons.com.
adam062 · 1 week and 5 days ago
Hello Mate - This is amazing piece of work and give me informative insights about subject matter. I would love to read more about your work to enhance my knowledge. Further, to get best TSplus Coupon Code , please visit out website www.uttercoupons.com.
adam062 · 1 week and 5 days ago
Hello Mate - This is amazing piece of work and give me informative insights about subject matter. I would love to read more about your work to enhance my knowledge. Further, to get best Promo code for stadium goods , please visit out website www.uttercoupons.com.
adam062 · 1 week and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: