I am trying to set up a script to automatically delete a .torrent file based on an output from transmission-remote.
transmission-remote http://localhost/transmission -l | grep 100% | grep Finished | awk '{print $10}' | xargs -I% -r -p -n 1 /bin/rm /mnt/samba/Dropbox/%.torrent
Here is my current output:
/bin/rm /mnt/samba/Dropbox/MyTorrent.torrent ?...y
/bin/rm: cannot remove `/mnt/samba/Dropbox/MyTorrent.torrent': No such file or directory
The name that is outputted is identical to the .torrent name
root@mfalc:/mnt/samba/Dropbox/# ls
MyTorrent.torrent
root@mfalc:/mnt/samba/Dropbox/#
Here is also what it looks like before the awk
root@mfalc:~# transmission-remote http://localhost/transmission -l | grep 100% | grep Finished | grep Done
12 100% 174.4 MiB Done 0.0 0.0 0.01 Finished MyTorrent
I have obscured the actual torrent name but, does anyone have any suggestions? Am I concatenating the .torrent extension with xargs correctly?
Well you don’t need
xargsfor that,awkcan do it for you (only that part):Even better
awkcan callrmon it:If you have space(s) in the torrent names: