We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 883959f commit 3f56fe1Copy full SHA for 3f56fe1
format.sh
@@ -0,0 +1,26 @@
1
+#!/bin/bash
2
+
3
+# 检查是否提供了文件名作为参数
4
+if [ "$#" -ne 1 ]; then
5
+ echo "Usage: $0 <file>"
6
+ exit 1
7
+fi
8
9
+input_file="$1"
10
+output_file="formatted_trackers.txt"
11
12
+# 检查文件是否存在
13
+if [ ! -f "$input_file" ]; then
14
+ echo "Error: File not found."
15
16
17
18
+# 使用tr将逗号替换为换行符,然后使用grep和sed来处理文件
19
+# - 使用grep -oP 来匹配以http://, https://, udp://, wss://开头并且以/announce结尾的内容
20
+# - 不进行贪婪匹配
21
+# - 去除每行末尾的所有空格或制表符
22
+tr ',' '\n' < "$input_file" | \
23
+grep -oP '(http|https|udp|wss)://[^/]+/announce' | \
24
+sed 's/[ \t]*$//' > "$output_file"
25
26
+echo "Formatted trackers have been saved to $output_file"
0 commit comments