azure - 为什么我可以在 Azure Cloud Shell Bash 中创建新文件和目录,但不能在 PowerShell 中创建?
问题描述
当我在 Azure Cloud Shell 中打开 Bash 时,我能够创建和编辑新文件和目录。
但是当我尝试在 Azure Cloud Shell 的 PowerShell 版本中执行此操作时,我无法执行任何这些操作。
例如,当我尝试创建一个新文件时:
Azure:/
PS Azure:\> new-item -Type file -Path my_new_files.txt
new-item : The node at path 'AzurePSDrive#Azure/my_new_files.txt' does not support the cmdlet 'New-Item'
At line:1 char:1
+ new-item -Type file -Path my_new_files.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (AzurePSDrive#Azure/my_new_files.txt:String) [New-Item], NodeDoesNotSupportCmdletException
+ FullyQualifiedErrorId : NewItem.NotSupported,Microsoft.PowerShell.Commands.NewItemCommand
当我尝试 cd 进入我已经从 Bash shell 创建的目录时:
Azure:/
PS Azure:\> ls
clouddrive jjj jjj.txt
Azure:/
PS Azure:\> cd jjj
cd : Cannot find path 'Azure:/jjj' because it does not exist.
At line:1 char:1
+ cd jjj
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (Azure:/jjj:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
为什么我可以在 Bash 中 mkdir、touch、cd 和 vi,但似乎没有一个文件/目录命令在 PowerShell 中有效?
解决方案
这是一个已知问题。 Azure:具有到您的主目录的虚拟映射。主目录存储在一个名为 $HOME 的变量中。
大多数 PowerShell cmdlet 不能很好地与 Azure:\ 别名配合使用。要克服这一点,只需键入:
cd $HOME
进入主目录后,您的 cmdlet 将按照您编写的方式运行。
推荐阅读
- algorithm - 已解决 - 从受最大化约束的矩阵中查找逐列最大元素
- sql - 此查询提供错误。你能提供一个答案吗?
- react-native - 如何在 React-native 中使用 react-native-image-picker 和 Redux
- prolog - 在序言中查找列表总和显示总和的因素,而不是最终总和结果
- python-3.x - 从子列表项中提取数值
- python - 如何处理 SQLite3 中的非确定性值?
- python - 模型范围 ORM django
- python - 访问列表中的此类元素
- python - 如何在python中读取类中的方法数?
- android-studio - 使用 Android 命令行工具从命令行更新 gradle 版本