|
@@ -0,0 +1,26 @@
|
|
|
|
+# Select-String
|
|
|
|
+
|
|
|
|
+> PowerShell์์ ๋ฌธ์์ด๊ณผ ํ์ผ์์ ํ
์คํธ๋ฅผ ์ฐพ์ต๋๋ค.
|
|
|
|
+> ์ฐธ๊ณ : ์ด ๋ช
๋ น์ด๋ PowerShell์ ํตํด์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค.
|
|
|
|
+> `Select-String`์ UNIX์ `grep`์ด๋ Windows์ `findstr.exe`์ ์ ์ฌํ๊ฒ ์ฌ์ฉํ ์ ์์ต๋๋ค.
|
|
|
|
+> ๋ ๋ง์ ์ ๋ณด: <https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/select-string>.
|
|
|
|
+
|
|
|
|
+- ํ์ผ ๋ด์์ ํจํด ๊ฒ์:
|
|
|
|
+
|
|
|
|
+`Select-String -Path "{{๊ฒฝ๋ก\๋์\ํ์ผ}}" -Pattern '{{๊ฒ์_ํจํด}}'`
|
|
|
|
+
|
|
|
|
+- ์ ํํ ๋ฌธ์์ด ๊ฒ์ (์ ๊ท์ ๋นํ์ฑํ):
|
|
|
|
+
|
|
|
|
+`Select-String -SimpleMatch "{{์ ํํ_๋ฌธ์์ด}}" {{๊ฒฝ๋ก\๋์\ํ์ผ}}`
|
|
|
|
+
|
|
|
|
+- ํ์ฌ ๋๋ ํ ๋ฆฌ์ ๋ชจ๋ `.ext` ํ์ผ์์ ํจํด ๊ฒ์:
|
|
|
|
+
|
|
|
|
+`Select-String -Path "{{*.ext}}" -Pattern '{{๊ฒ์_ํจํด}}'`
|
|
|
|
+
|
|
|
|
+- ํจํด๊ณผ ์ผ์นํ๋ ์ค ์๋ค์ ์ง์ ๋ ์ค ์ ์บก์ฒ:
|
|
|
|
+
|
|
|
|
+`Select-String --Context {{2,3}} "{{๊ฒ์_ํจํด}}" {{๊ฒฝ๋ก\๋์\ํ์ผ}}`
|
|
|
|
+
|
|
|
|
+- `stdin`์์ ํจํด๊ณผ ์ผ์นํ์ง ์๋ ์ค ๊ฒ์:
|
|
|
|
+
|
|
|
|
+`Get-Content {{๊ฒฝ๋ก\๋์\ํ์ผ}} | Select-String --NotMatch "{{๊ฒ์_ํจํด}}"`
|