rtorrent批量添加magnetlink

#!/bin/bash
cnt=1
cd /home/gyx/watch || exit    # set your watch directory here
cat 1.txt|while read i 
do
[[ "$i" =~ xt=urn:btih:([^&/]+) ]] || exit
echo "d10:magnet-uri${#i}:${i}e" > "${cnt}.torrent" # name .torrent file by variable cnt
cnt=$[cnt+1]
done

编程技巧