Windows Powershell의 Unix cat -e 아날로그는 무엇입니까?

Windows Powershell의 Unix cat -e 아날로그는 무엇입니까?

저는 Windows 10 Powershell을 사용하고 있으며 NEWLINE 앞에 각 줄의 끝 부분에 인쇄된 $ 문자가 있는 파일 내용을 보고 싶습니다.

UNIX 계열 시스템에서는 다음을 수행할 수 있습니다 cat -e file_name. Powershell에서 동일한 결과를 얻을 수 있습니까?

답변해 주셔서 미리 감사드립니다.

답변1

내 의견에서 계속하면 이렇게 할 수 있습니다 ...

원본 파일 내용 ---

Get-Content -Path 'D:\temp\book1.txt'
# Results
<#
Site,Dept
Main,aaa,bbb,ccc
Branch1,ddd,eee,fff
Branch2,ggg,hhh,iii
#>

수정된 파일 내용 ---

이것을 사용하십시오 ...

(Get-Content -Path 'D:\temp\book1.txt'  -Raw).Replace("`r", "$")

... 아니면 이거.

(Get-Content -Path 'D:\temp\book1.txt'  -Raw) -Replace("`r", "$") 

# Results
<#
Site,Dept$ 
 Main,aaa,bbb,ccc$ 
 Branch1,ddd,eee,fff$ 
 Branch2,ggg,hhh,iii$ 
#>

중요한 점은 변경 내용을 저장하거나 새 파일에 쓰려면 여전히 Set-Content cmdlet을 사용해야 한다는 것입니다.

(Get-Content -Path 'D:\temp\book1.txt'  -Raw).Replace("`r", "$") | 
Out-File -FilePath 'D:\temp\book1Modified.txt'

Get-Content -Path 'D:\temp\book1Modified.txt'
# Results
<#
Site,Dept$
Main,aaa,bbb,ccc$
Branch1,ddd,eee,fff$
Branch2,ggg,hhh,iii$
#>

관련 정보