how to convert powershell script to bash script

Saidireddy Gayam 1 Reputation point
2022-04-08T04:06:29.763+00:00

Hi ,
Please suggest how can i convert below PowerShell script to bash script.

$Project.name = "Sampleproject"
$doc = New-Object System.Xml.XmlDocument
$doc.Load("C:\xml\project.xml")
$Project = $doc.SelectSingleNode("//Project[@DeezNutz ]")

$DeploymentSet = $doc.SelectSingleNode("//DeploymentSet[@DeezNutz ]")
$DeploymentSet.name = $Project.name + "DeploymentSet"

$Composite = $doc.SelectSingleNode("//Composite[@DeezNutz ]")
$Composite.name = $Project.name
$Composite = $doc.SelectSingleNode("//Composite[@displayName ]")
$Composite.displayName = $Project.name

$DeploymentMap = $doc.SelectSingleNode("//DeploymentMap[@DeezNutz ]")
$DeploymentMap.name = $Project.name + "DeploymentMap"

$MapSetMapping = $doc.SelectSingleNode("//MapSetMapping[@mapName]")
$MapSetMapping.mapName = $Project.name + "DeploymentMap"
$MapSetMapping = $doc.SelectSingleNode("//MapSetMapping[@setName]")
$MapSetMapping.setName = $Project.name + "DeploymentSet"

$doc.Save("C:\xml\project.xml")

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,360 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 44,776 Reputation points
    2022-04-08T18:47:35.27+00:00

    Bash is a shell. That PowerShell script deals mostly with the extraction and modifications of values in elements within a XML file. What tool(s) do you have available to you that will process XML documents that run with the operating system running the bash shell?