You are not logged in.
Pages: 1
Since I'm a dirty TF2 idler and I use Source Tools to idle, it uses a list of servers from a servers.txt file.
A list of idling servers is here: http://tf2stats.net/blacklist_generate/ … ourcetools
The list is in this format:
{IP ADDRESS}:{PORT};{SERVER NAME}
Unfortunately, I can't just save that as the list, because it thinks you're trying to send {SERVER NAME} as a command or something.
There's ~920 lines that are just that and so I need to remove everything AFTER the port number (so it would be the colon and the server name).
The tricky part is that not all ports are the same. 27015 is the standard, some use 27016, and some use other ones. So I need to have a sed command to remove everything past a colon on all lines, then remove the colon on all lines.
And since I suck at sed, I've come crawling to the forums for help. So please, help.
Last edited by Arm-the-Homeless (2010-04-05 23:47:19)
Offline
Um, sed 's/\(.*\):\([[:digit:]]*\);\(.*\)/\1/g' will give you just the IPs. Replacing '\1' with '\2' will get you the port, and '\3' gets you the server name. '\1:\2' will get you {SEVER}:{PORT}.
Offline
alternatively you could do it in pure bash too.
(
IFS=$'\n'; while read -r; do
echo "${REPLY%%;*}"
done < <(wget -q -O - "http://thaturl.com")
) > ./serverlist.txt
that would get your list of server:port in a text file.
//github/
Offline
Thanks. Just what I needed.
Offline
@tavianator: If the server name has a : and ; in the server name then that won't work. Instead use [^:]*: and [^;]*;
@brisbin33: if you're going to redefine IFS, why not to :; with while read ip port name
Offline
@brisbin33: if you're going to redefine IFS, why not to :; with while read ip port name
true story. IFS=$'\n'; while read -r is just a habit i fall back on when i want to read [possibly inconsistent] lines out of a file.
//github/
Offline
Pages: 1