-
Notifications
You must be signed in to change notification settings - Fork 0
/
PowerShellBashEquivalent
56 lines (35 loc) · 1005 Bytes
/
PowerShellBashEquivalent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Bash to PowerShell
Sometimes you need to leave your favorite tool to use a lesser loved one...
## variable and env vars
read:
`$<variable-name>`
`$Env:<variable-name>`
set:
`$<variable-name>=<numerical value>`
`$<variable-name>="<text value>"`
`$Env:<variable-name>=<var value>`
## multi line command
| bash | powershell
|:-----|:----------|
| \ | \` |
exemple:
```
docker run `
-env var1=val1 `
myimage:latest
```
## chaining commands
in PowerShell, use a semicolon to chain commands :
`ipconfig /release ; ipconfig /renew `
Use the `&&` or `||`operators to execute conditionnaly second command.
## GREP => Select-String
Basic usage:
`grep <searchedString> <file>`
`Select-String <searchedString> <file>`
*searchedString* can be a regexp
to search lines that do not contains use `-NotMatch` option
`grep -v <searchedString> <file>`
`Select-String -NotMatch <searchedString> <file>`
## rm -rf
`rm -rf <pathto-remove>`
`Remove-Item -Force -Recurse -Path "<pathto-remove>"`