Skip to content

Instantly share code, notes, and snippets.

@hfs
Created November 21, 2013 12:37
Show Gist options
  • Save hfs/7580876 to your computer and use it in GitHub Desktop.
Save hfs/7580876 to your computer and use it in GitHub Desktop.
Script to copy a number of files to a remote host using SFTP. Files are first copied to have a leading dot in the filename and then remotely renamed to their real name. This is useful when large files are copied, a remote process waits for them, it should not "see" unfinished files and it follows the convention to ignore files with a leading dot…
#!/bin/sh
#
# Script to copy a number of files to a remote host using SFTP. Files are first
# copied to have a leading dot in the filename and then remotely renamed to
# their real name. This script creates the input for the 'sftp' command.
#
# Usage:
# sftp-cp * | sftp user@host:/target/directory
for each in "$@"; do
echo "put \"$each\" \".$each\""
echo "rename \".$each\" \"$each\""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment