Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash export command in powershell

I'm trying to follow this guide to test Django on Azure: https://github.com/carltongibson/rest-framework-tutorial/blob/master/docs/azure/2-appservice.md , however i'm stuck at running the following command since i'm doing it from PowerShell:

$ export $(grep -v '^#' .azure-env | xargs)

What would the command be in PowerShell and can someone explain what it does ?

Thanks

like image 969
Renm Avatar asked Feb 12 '19 09:02

Renm


1 Answers

The description of the shell command is already in the document that you provide.

$ export $(grep -v '^#' .azure-env | xargs)

This uses grep to go through your .azure-env file excluding any lines that are comments, passing any values into xargs so they will be formatted to be interpreted by the shell. We then export these so they´re passed as environment variables to the commands we envoke.

And you can convert the shell command into PowerShell like this:

Get-Content .\azure.txt | Select-String -NotMatch "^#" | ForEach-Object { 
    $array= $_[0].ToString().split("=")
    [System.Environment]::SetEnvironmentVariable($array[0], $array[1])
    }

The screenshot of the result shows here:

enter image description here

like image 170
Charles Xu Avatar answered Sep 26 '22 13:09

Charles Xu