一、查看本机的互联网ip
curl ipinfo.io/ip
curl ifconfig.me
http://https://ipinfo.io/ip
https://ifconfig.me
二、grep提取http/https链接
grep -oE 'https?://[^ ]+' result.txt
- **
grep
**:Linux 文本搜索工具。
- **
-o
**:仅输出匹配到的内容(而非整行)。
- **
-E
**:启用扩展正则表达式(Extended Regular Expressions),支持 ?
、+
等符号。
- **
'https?://[^ ]+'
**:正则表达式,匹配 URL。
正则表达式分解
(1) http
字面匹配:匹配字符串 http。
(2) s?
s?:匹配0 或 1 个 s 字符。
例如:http(无 s)或 https(有 s)。
? 是扩展正则中的符号,表示“可选”。
3) ://
字面匹配:匹配协议后的固定字符 ://。
(4) [^ ]+
[^ ]:匹配任意非空格字符。
^ 在方括号内表示“否定”,即排除空格。
+:匹配 1 个或多个前面的字符(即非空格字符)。
例如:http://example.com:8080/path 会被完整匹配,直到遇到空格或行尾。