Last Updated: February 25, 2016
·
846
· lutzky

Avoid typing long directory names with scp

Manually copying a file between servers, which should go in the same directory? Here's a shortcut:

Instead of:

scp /long/ass/directory/name/filename.ext \
    otherserver:/long/ass/directory/name/filename.ext

Do:

cd /long/ass/directory/name
scp filename.ext otherserver:$PWD

Or add this to .bashrc:

scpsd() { # scp to same directory
    scp $1 $2:$PWD
}

...and use like so:

cd /long/ass/directory/name
scpsd filename.ext otherserver