Bash loop to move directories on a remote host via ssh
- by I Forgot
I'm trying to figure out a way to perform the following loop on a remote host via ssh.
Basically it renames a series of directories to create a rotating backup. But it's local. I want it to work against directories on a remote host.
while [ $n -gt 0 ];
do {
src=$(($n-1))
dst=$n
if [ -d /backup/$src ];
then {
mv /backup/$src /backup/$dst;
}
fi;
}
((n--))
done;