본문 바로가기

Windows 10/PowerShell

PowerShell : Get-Content, Set-Content, Out-File (파일 입출력)

반응형
  • Get-Content (파일 읽기)

    Get-Content "C:\TEST.txt"
  • Set-Content (파일 출력)

    Set-Content "C:\TEST.txt" "저장할 파일 내용"
  • 파이프라인을 이용한 파일 저장

     ls "C:\" | Set-Content "C:\TEST.txt"
  • Out-File 명령어를 이용한 파일 저장 (Set-Content와 다르게 모든 값이 저장)

     ls "C:\" | Out-File "C:\TEST.txt"

 

 

Get-Content (Microsoft.PowerShell.Management)

The Get-Content cmdlet gets the content of the item at the location specified by the path, such as the text in a file or the content of a function. For files, the content is read one line at a time and returns a collection of objects, each of which represe

docs.microsoft.com

 

Set-Content (Microsoft.PowerShell.Management)

Set-Content is a string-processing cmdlet that writes new content or replaces the content in a file. Set-Content replaces the existing content and differs from the Add-Content cmdlet that appends content to a file. To send content to Set-Content you can us

docs.microsoft.com

 

Out-File (Microsoft.PowerShell.Utility)

The Out-File cmdlet sends output to a file. When you need to specify parameters for the output use Out-File rather than the redirection operator (>).

docs.microsoft.com

 

반응형

'Windows 10 > PowerShell' 카테고리의 다른 글

PowerShell : Registry  (0) 2019.08.21
PowerShell : Get-ChildItem (ls), 응용  (0) 2019.07.14
PowerShell : 기본 명령어  (0) 2019.06.16
PowerShell : Alias  (0) 2019.06.15
PowerShell : 특수문자  (0) 2019.06.15