Last active
December 23, 2015 14:39
-
-
Save maimai-swap/6650286 to your computer and use it in GitHub Desktop.
リモートのディレクトリで番号が新しくて無い奴をローカルにつくってファイルを持ってくる。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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