gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
fastest way to get the ip from proxy strings like socks4://ip:port in bash
- User
fastest way to get the ip from proxy strings like socks4://ip:port in bash
- Assistant
If you have proxy strings in the format
socks4://ip:portand you want to extract the IP address efficiently using Bash, you can use tools likesed,awk, orcut. Here are a few different methods you might find useful:Using
sedYou can use
sedto extract the IP part:proxy_string="socks4://192.168.1.1:1080" ip=$(echo "$proxy_string" | sed -E 's|^socks4://([^:]+):[0-9]+$|\1|') echo "$ip"Using
awkYou can also use
awkto split the string: