Xargs -I% / path /%
If a torrent has a problem deleting hard disk data in the id column, it has a number such as "ID *".
I want to filter out torrent IDs in the torrent list that have a "*" at the end of the ID (LIKE ID * or 1 *, 2 *, 25 *) and remove them from the torrent list.
Full command:
/usr/bin/transmission-remote 127.0.0.1:9091 --auth ts:ts -l | grep "*" | awk '{print $1}' \
| xargs -n 1 -I % /usr/bin/transmission-remote 127.0.0.1:9091 --auth ts:ts -t% -r
I expected the result:
/usr/bin/transmission-remote 127.0.0.1:9091 --auth ts:ts -t ID* -r
But something went wrong. The broadcast said that:
127.0.0.1:9091/transmission/rpc/ responded: "success"
But the torrent was not removed from the list.
How can I see the end result to compare with what I expect?
+3
source to share
1 answer
To get ids:
transmission-remote -l | grep '*' | awk '{print $1}' | grep -o '[0-9]*'
Full command:
transmission-remote -l | grep '*' | awk '{print $1}' | grep -o '[0-9]*' | tr "\\n" "," | xargs -n 1 -I \% transmission-remote -t \% -r
Done and Done (: With an additional improvement to use "tr" to join all torrents and avoid running everything in a loop (Transmission-RPC is extremely resource intensive to call multiple times)
0
source to share