2013-03-07 2 views
4

PowerShell에서 캐리지 리턴 및 줄 바꿈 (예 : ~)} {{E})을 찾아서 바꿀 수있는 방법이 있습니까? \ r \ nE)?PowerShell에서 줄 바꿈 문자로 찾기/바꾸기

$filenames = @("E:\blergfest.csv") 
foreach ($file in $filenames) { 
    $outfile = "$file" + ".out" 

    Get-Content $file | Foreach-object { 
     $_ -replace '\~}}|{{E', '\r\nE' ` 
      -replace '\|\r\n', '\r\n' 
    } | Set-Content $outfile 
} 

답변

2

이 방법에 대해 :

$filenames = @("E:\blergfest.csv") 
foreach ($file in $filenames) { 
    $outfile = "$file" + ".out" 

    Get-Content $file | Foreach-object { 
     $_ -replace '\~}}|{{E', "`r`nE" ` 
      -replace '\|\r\n', "`r`n" 
    } | Set-Content $outfile 
} 
+1

은 당신이 같은 진술하도록 요청하는 너무 많은 수 있을까요 "교체 텍스트에'역음을 사용을 \''대신 백 슬래시''\'', 아래 등" (?) –

2

캐리지 리턴과 라인 피드와 제어 문자, 큰 따옴표를 사용하여 역 따옴표를 사용하는 것이 포함 된 문자열을 만들려면 예를 들어

문자`는 파워 쉘 이스케이프 코드입니다. 이처럼 :

"`r`nE" 
관련 문제