Slackware This Forum is for the discussion of Slackware Linux.
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
03-05-2021, 02:52 PM
#1
Senior Member
Registered: Apr 2015
Posts: 1,201
Rep:
What is the quickest way to get from 1025-65535?
I'm working on something and need this format from 1025-65535 TCP/UDP. Thanks
Code:
192.168.0.12,udp:1024
03-05-2021, 03:01 PM
#2
Senior Member
Registered: Mar 2020
Posts: 3,670
Rep:
You mean something like netstat -atun or ss -atun ?
Last edited by shruggy; 03-05-2021 at 03:06 PM .
03-05-2021, 03:05 PM
#3
Senior Member
Registered: Apr 2015
Posts: 1,201
Original Poster
Rep:
I would like all the ports listed from 1025 to 65535 with every port in between in tcp and udp in the format I posted above.
192.168.0.12,udp:1024
192.168.0.12,tcp:1024
192.168.0.12,udp:1025
192.168.0.12,tcp:1025
etc....
Last edited by PROBLEMCHYLD; 03-05-2021 at 03:06 PM .
03-05-2021, 03:11 PM
#4
Senior Member
Registered: Mar 2020
Posts: 3,670
Rep:
Code:
awk -F'[ \t/]+' '
$2>1024&&$3~/^(udp|tcp)$/{print "192.168.0.12,"$3":"$2}
' /etc/services
03-05-2021, 03:13 PM
#5
LQ Guru
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792
If you mean just a list of them, you could use the following script. If desired, you could redirect the output of the script into a file.
Code:
for i in `seq 1025 65535`; do
echo "192.168.0.12,udp:$i"
echo "192.168.0.12,tcp:$i"
done
This was just written off the top of my head without testing... it might need a bit of tweaking.
1 members found this post helpful.
03-05-2021, 03:16 PM
#6
Senior Member
Registered: Jan 2007
Location: Paris, France
Distribution: Slackware-15.0
Posts: 1,405
You need text file ? Stdout ?
First in mind comes a for loop
Code:
for i in [1025-65535]; do echo 198.168.0.12,udp:$i/n198.168.0.12,tcp:$i; done
03-05-2021, 03:20 PM
#7
LQ Guru
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792
Quote:
Originally Posted by
Tonus
You need text file ? Stdout ?
First in mind comes a for loop
Code:
for i in [1025-65535]; do echo 198.168.0.12,udp:$i/n198.168.0.12,tcp:$i; done
Doesn't this require
echo -e to support the newline escape?
03-05-2021, 03:26 PM
#8
Senior Member
Registered: Apr 2015
Posts: 1,201
Original Poster
Rep:
Quote:
Originally Posted by
bassmadrigal
If you mean just a list of them, you could use the following script. If desired, you could redirect the output of the script into a file.
Code:
for i in `seq 1025 65535`; do
echo "192.168.0.12,udp:$i"
echo "192.168.0.12,tcp:$i"
done
This was just written off the top of my head without testing... it might need a bit of tweaking.
Seems to work but it doesn't create a log file. Pretty damn fast too.
for i in `seq 1025 65535`; do
echo "192.168.0.12,udp:$i"
echo "192.168.0.12,tcp:$i"
done < /home/problemchyld/Desktop/ports.log
03-05-2021, 03:26 PM
#9
Senior Member
Registered: Mar 2020
Posts: 3,670
Rep:
Quote:
Originally Posted by
bassmadrigal
Doesn't this require echo -e to support the newline escape?
Sure. It does require
echo -e , curly braces for brace expansion and backslash escape for
\n .
Another option
Code:
seq -f'192.168.0.12,udp:%.f' 1025 65536|sed 'p;s/udp/tcp/'
Quote:
Originally Posted by
PROBLEMCHYLD
done < /home/problemchyld/Desktop/ports.log
Greater than:
>
Last edited by shruggy; 03-05-2021 at 03:28 PM .
1 members found this post helpful.
03-05-2021, 03:29 PM
#10
Senior Member
Registered: Apr 2015
Posts: 1,201
Original Poster
Rep:
Quote:
Originally Posted by
shruggy
Sure. It does require
echo -e , curly braces for brace expansion and backslash escape for
\n .
Another option
Code:
seq -f'192.168.0.12,udp:%.f' 1025 65536|sed 'p;s/udp/tcp/'
Greater than: >
This one liner works too. Thanks but the log file is not listing anything.
03-05-2021, 03:30 PM
#11
Senior Member
Registered: Apr 2015
Posts: 1,201
Original Poster
Rep:
Thanks shruggy and bass and all who helped. Problem solved.
03-05-2021, 03:32 PM
#12
Senior Member
Registered: Mar 2020
Posts: 3,670
Rep:
Quote:
Originally Posted by
PROBLEMCHYLD
the log file is not listing anything.
Code:
seq -f'192.168.0.12,udp:%.f' 1025 65536|sed 'p;s/ud/tc/' >/home/problemchyld/Desktop/ports.log
Last edited by shruggy; 03-07-2021 at 08:35 AM .
1 members found this post helpful.
All times are GMT -5. The time now is 04:34 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News