Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
684 views
in Technique[技术] by (71.8m points)

linux - Does scp create the target folder if it does not exist


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

To achieve the task with ssh and scp (instead of rsync):

Solution

Lets break into 2 steps :

1. Create directory if missing:

ssh [email protected] "mkdir -p /data/install/somefolder"

2. Copy to it:

scp -r /data/install/somefolder [email protected]:/data/install/somefolder

Put them together

server="[email protected]"
destiny="/data/install/somefolder"
src="/data/install/somefolder"
ssh "$server" "mkdir -p $destiny" && scp -r "$src" "$server:$destiny"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...