Назад | Перейти на главную страницу

Как показать окончания строк и управляющие символы в файле на Windows Server?

У меня возникли проблемы с моими серверами Windows, когда мне нужно добавить --server для запуска Puppet, иначе он не будет работать, несмотря на то, что в файле конфигурации указан правильный сервер. Мне интересно, есть ли окончание строки Linux вместо crlf Windows. Какой простой способ проверить это в окне Windows?

Или воспользуйтесь быстрым взломом VBS:

'
' Save this as "myscript.vbs" and then execute from command line like:
'   cscript.exe myscript.vbs "<file to check>"
'
Option Explicit
On Error Resume Next
Err.Clear
Dim objArgs
Dim objFSO
Dim objTextFile
Dim strFileContentsIn
Dim strFileContentsOut
Dim intCharIndex
strFileContentsOut = ""
Set objArgs = WScript.Arguments
If Err.Number <> 0 Then
    WScript.Echo "ERROR : Bad args."
    Err.Clear
Else
    Set objFSO = CreateObject( "Scripting.FileSystemObject" )
    If Err.Number <> 0 Then
        WScript.Echo "ERROR : Failed to create File System Object."
        Err.Clear
    Else
        Set objTextFile = objFSO.OpenTextFile( objArgs.Item(0) )
        If Err.Number <> 0 Then
            WScript.Echo "ERROR : Failed to open file."
            Err.Clear
        Else
            strFileContentsIn = objTextFile.ReadAll
            If Err.Number <> 0 Then
                WScript.Echo "ERROR : Failed to read file."
                Err.Clear
            Else
                For intCharIndex = 1 To Len( strFileContentsIn )
                    If ( Asc(Mid( strFileContentsIn, intCharIndex, 1 )) = 10 ) Then
                        strFileContentsOut = strFileContentsOut & "\n" & VbCrLf
                    ElseIf ( Asc(Mid( strFileContentsIn, intCharIndex, 1 )) = 13 ) Then
                        strFileContentsOut = strFileContentsOut & "\r"
                    Else
                        strFileContentsOut = strFileContentsOut & Mid( strFileContentsIn, intCharIndex, 1 )
                    End If
                Next
                WScript.Echo strFileContentsOut
            End If
            objTextFile.Close
            Set objTextFile = Nothing
        End If
        Set objFSO = Nothing
    End If
End If

Альтернативная, более короткая версия PowerShell. Все еще не родная команда: \

(([IO.File]::ReadAllText( "<filepath>" ) -replace "`r", "\r") -replace "`n", "\n")