cd
更改或查看 SFTP 或 FTP 服务器上的当前文件夹
说明
示例
更改文件夹和列表内容
通过创建 SFTP 对象打开与 SFTP 服务器的连接。使用 SFTP 对象列出服务器上子文件夹的内容。在 SFTP 会话结束后,关闭连接。
首先,连接到示例 SFTP 服务器。
s = sftp("sftp.example_galapagos.net","jsmith")
SFTP with properties: Host: "sftp.example_galapagos.net" Username: "jsmith" Port: 22 ServerSystem: "unix" DatetimeType: "datetime" ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix RemoteWorkingDirectory: "/home/jsmith"
列出顶层文件夹的内容。
dir(s)
air_quality fish insects README.txt birds INDEX.txt mammals reptiles climate index.html rainfall sftp.html
使用 dir
函数列出子文件夹的内容。
dir(s,"home/jsmith/birds")
albatrosses ducks herons parrots avocets_stilts falcons kingfishers pelicans barn_owls flamingos mockingbirds penguins blackbirds frigatebirds nightjars pheasants boobies grebes northern_storm_petrels pigeons cardinal grosbeaks guineafowl osprey plovers cormorants gulls owls rails cuckoos hawks oystercatcher sandpipers
使用 cd
函数切换到子文件夹。cd
的输出是 SFTP 服务器上当前文件夹的路径,而不是当前 MATLAB 文件夹的路径。
cd(s,"home/jsmith/birds/herons")
ans = "home/jsmith/birds/herons"
列出当前文件夹的内容。
dir(s)
documentation great_egret_data migration_patterns great_blue_heron_data green_heron_data nesting_behaviors
关闭与 SFTP 服务器的连接。您也可以通过删除 SFTP 对象或让连接超时来关闭连接。
close(s)
输入参数
s
— 连接到 SFTP 或 FTP 服务器
SFTP 对象 | FTP 对象
与 SFTP 或 FTP 服务器的连接,指定为 SFTP 对象或 FTP 对象。
folder
— 目标文件夹的名称
字符向量 | 字符串标量
SFTP 或 FTP 服务器上的目标文件夹的名称,指定为字符向量或字符串标量。要指定当前文件夹的上一级文件夹,请使用 '..'
。
提示
将
~
符号传递给cd
函数以导航到登录文件夹。
版本历史记录
在 R2006a 之前推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)