Bash loop to move directories on a remote host via ssh
Posted
by
I Forgot
on Server Fault
See other posts from Server Fault
or by I Forgot
Published on 2012-04-14T19:34:54Z
Indexed on
2012/04/14
23:33 UTC
Read the original article
Hit count: 287
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;
© Server Fault or respective owner