bash bash命令将文件从一台计算机复制到另一台计算机

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11208895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 22:19:37  来源:igfitidea点击:

bash command to copy file from one computer to another

macosbashunixcp

提问by MorganR

Wasn't quite sure how to word this but let's say I've used sshto remote into my friends MacBook (macbook_b) from my MacBook (macbook_a).

不太确定如何表达这一点,但假设我曾经ssh从我的 MacBook (macbook_a) 远程连接到我的朋友 MacBook (macbook_b)。

What command would I use to copy a file/directory to my MacBook (macbook_a) from my friends MacBook (macbook_b)?

我将使用什么命令将文件/目录从我的朋友 MacBook (macbook_b) 复制到我的 MacBook (macbook_a)?

Thank you.

谢谢你。

回答by maxwell

You can use scp (Secure Copy).

您可以使用 scp(安全复制)。

To copy FROM your machine to friends:

从您的机器复制到朋友:

scp file_to_copy [email protected]:/path/to/location

In another direction:

在另一个方向:

scp [email protected]:/path/locatio/file_name file_name

If you need to copy an entire directory, you'll need to use the recursive flag, like this:

如果需要复制整个目录,则需要使用递归标志,如下所示:

scp -r directory_to_copy [email protected]:/path/to/location

回答by Terje Mikal

Assuming you're logged in on macbook_b:

假设您已登录 macbook_b:

scp file_to_copy username@macbook_a:/path/to/destination

or if you're logged in on macbook_a:

或者如果您已登录 macbook_a:

scp username@macbook_b:/path/to/file_to_copy local_destination

回答by Siva Karthikeyan

I think this linkwould help you with the answer you are looking for. In this you can use scp ssh source destination example for your scenario you have requested for.

我认为此链接将帮助您找到您正在寻找的答案。在这种情况下,您可以将 scp ssh 源目标示例用于您请求的场景。

Also refer to this questionwhich has been already answered. It might help.

另请参阅已经回答的这个问题。它可能会有所帮助。

回答by Sanjay Rao

first do pwd to get the path to the file of your friends macbook then

首先执行 pwd 以获取您朋友的 macbook 文件的路径,然后

go into your machine's ssh window and do

进入您机器的 ssh 窗口并执行

scp user_name@machine_name(of your friend's):(copy the path after executing pwd)/file_name .(dot means your your current directory)

scp user_name@machine_name(of your friend):(执行pwd后复制路径)/file_name .(点表示你的当前目录)

enter his password !

输入他的密码!

voila !!!

瞧!!!