Skip to content

Instantly share code, notes, and snippets.

@pd12bb
Created September 29, 2020 11:15
Show Gist options
  • Select an option

  • Save pd12bb/c9601d143a706a729f1770cb98a8c6d2 to your computer and use it in GitHub Desktop.

Select an option

Save pd12bb/c9601d143a706a729f1770cb98a8c6d2 to your computer and use it in GitHub Desktop.
#!/bin/bash
## vmess订阅生成脚本,参数1为节点信息的jsonc 列表,参数2为输出
raw=$(cat "$1" | sed -e 's/\/\/.*//g' -e 's/[[:blank:]]*$//g' -e 's/^[[:blank:]]*//g' | tr -d '\n' | sed -e 's/}{/}\n{/g')
target="$2"
number=$(echo "$raw" | grep -c '{')
for ((i=1;i<="$number";i++)); do
encoded=$(echo "$raw" | sed -n -e "${i} p" | base64 -w 0)
vmess[$i]="vmess://${encoded}"
done
echo ${vmess[@]} | tr ' ' '\n' | base64 -w 0 > "${target}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment