Skip to content

Instantly share code, notes, and snippets.

@maimai-swap
Last active December 23, 2015 14:39
Show Gist options
  • Save maimai-swap/6650286 to your computer and use it in GitHub Desktop.
Save maimai-swap/6650286 to your computer and use it in GitHub Desktop.
リモートのディレクトリで番号が新しくて無い奴をローカルにつくってファイルを持ってくる。
#!/bin/sh
LOCAL_JOB_HOME=/home/myname/downloader
REMOTE_JOB_HOME=/data/downloader/job
ls -1 $LOCAL_JOB_HOME/wait | sort -n > $LOCAL_JOB_HOME/wait_local
ssh myname@remotehost ls $REMOTE_JOB_HOME/wait | sort -n > $LOCAL_JOB_HOME/wait_remote
remote=`comm -3 $LOCAL_JOB_HOME/wait_remote $LOCAL_JOB_HOME/wait_local | awk -F"\t" '{print $1}' | grep "[0-9]"`
for r in $remote
do
echo "get $r"
mkdir $LOCAL_JOB_HOME/wait/$r
scp myname@remotehost:$REMOTE_JOB_HOME/wait/$r/* $LOCAL_JOB_HOME/wait/$r/.
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment