특정 텍스트 파일을 select-string 으로 읽어서 pattern을 install로 주어서 txt파일 내의 install이 들어간 줄을 출력하는 스크립트가 있습니다.
문제는 이 결과를 다른 txt로 저장해서 보면 이렇게 나옵니다.
좀 보기 불편하게 쓸데없는 공백라인이 있고 네번째줄의 경우 강제로 줄바꿈도 되어있구요
install.txt:65:4 Installed KB2698365 2 MB Windows Server 2008 R2 x64 Edition용 보안 업데이트(KB2698365)
install.txt:66:4 Installed KB2719985 2 MB Windows Server 2008 R2 x64 Edition용 보안 업데이트(KB2719985)
install.txt:67:4 Installed KB2712808 786 KB Windows Server 2008 R2 x64 Edition용 보안 업데이트(KB2712808)
install.txt:68:4 Installed KB981391 81 KB Windows Server 2008 R2 x64 Edition용 Active Directory Rights Management Ser
vices의 모범 사례...
install.txt:69:4 Installed KB2386667 105 KB Windows Server 2008 R2 x64 Edition용 응용 프로그램 서버의 모범 사례 분석기 업데이트(KB2386667)
이상해서 방법을 찾다가 powershell의 창 속성-> 레이아웃에 들어가서 화면 버퍼와 창크기 가로사이즈를 150으로 늘렸습니다(기본 120) 그리고 나서 같은 스크립트를 돌렸더니 이렇게 나옵니다.
보니까 파워쉘의 가로 크기만큼 출력되고 그 이상 넘어가는 줄은 강제로 줄바꿈 해버리는것 같은데요.
이거 파워쉘 창의 속성에 따라 결과가 이렇게 나온다면 이 스크립트가지고 실행할 서버마다 속성을 다 바꿔줘야 된다는 얘긴데 말이 안되는 것 같고, 환경의 영향없이 원하는 결과(공백라인 없이)를 얻을 방법이 없을까요?
install.txt:4:install.txt:65:4 Installed KB2698365 2 MB Windows Server 2008 R2 x64 Edition용 보안 업데이트(KB2698365)
install.txt:5:install.txt:66:4 Installed KB2719985 2 MB Windows Server 2008 R2 x64 Edition용 보안 업데이트(KB2719985)
install.txt:6:install.txt:67:4 Installed KB2712808 786 KB Windows Server 2008 R2 x64 Edition용 보안 업데이트(KB2712808)
install.txt:7:install.txt:68:4 Installed KB981391 81 KB Windows Server 2008 R2 x64 Edition용 Active Directory Rights Management Services의 모범 사례...
install.txt:8:install.txt:69:4 Installed KB2386667 105 KB Windows Server 2008 R2 x64 Edition용 응용 프로그램 서버의 모범 사례 분석기 업데이트(KB2386667)
Comment 1
-
우주인(김재훈)
2013.01.09 18:22
out-file로 결과를 저장하시는 것 같은데요
set-content로 해보세요
Select-String -Pattern "Install" -Path "원본파일" | set-content d:\test.txt