简体   繁体   English

直接访问远程/集群上的文件

[英]Access a file on remote/cluster directly

I am trying to compare two files one local and other one on remote.我正在尝试比较两个文件,一个是本地文件,另一个是远程文件。 I used我用了

meld a.txt user@host:/home/user/john/b.txt

This was not possible because file could not be detected.这是不可能的,因为无法检测到文件。 However, I could copy the same file from the same location to local via scp and do the comparison afterwards.但是,我可以通过scp将同一个文件从同一个位置复制到本地,然后进行比较。 How to access the file directly on cluster for example like:如何直接在集群上访问文件,例如:

vim user@host:/home/user/john/b.txt

In bash, you can create a file from a process with <(...) :在 bash 中,您可以使用<(...)从进程创建文件:

meld a.txt <(ssh user@host cat /path/to/file/b.txt)

If you want to modify the remote file, you'll have to use some mounting.如果要修改远程文件,则必须使用一些挂载。

One way to do it is to use sshfs一种方法是使用sshfs

# sshfs setup
mkdir ~/remote
sshfs user@host:/path/to/file ~/remote

# meld invocation
meld a.txt ~/remote/b.txt

Try save the remote file to your linux system and simply use diff -y file1 file2 command.尝试将远程文件保存到您的 linux 系统并简单地使用diff -y file1 file2命令。 You will see the diff between.你会看到两者之间的差异。

Check the path in your example, I think it's incorrect.检查您示例中的路径,我认为它不正确。 Try directly:直接试试:

vim john@server:b.text

That should work.那应该行得通。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM