"more" command broken?

Welcome Forums General PowerShell Q&A "more" command broken?

This topic contains 8 replies, has 4 voices, and was last updated by

3 months, 2 weeks ago.

  • Author
  • #112939

    Points: 0
    Rank: Member

    I need to use something like

    type foobar.txt | more /P >convert.txt

    using CMD there is a "to many arguments"-Error

    using PS there is an error too
    +         Get-Content $file | more.com
    +         ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (G:\p:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand

    I need to use /P to convert unix-style text to windows-style test.

  • #112946

    Points: 1,091
    Helping Hand
    Rank: Community Hero

    more in PowerShell is not more.com, it is a function which is uses more.com without any parameter.

    You could do,

    # To see what is in more function
    # What you can do instead
    Get-Content foobar.txt | C:\Windows\System32\more.com /P
  • #112960

    Points: 0
    Rank: Member

    Does MORE under PS less than more.com?

    I only tried PS, because of more.com gave me an error "too many arguments" if I use the switch "/P" ... And maybe you can xcheck if more.com works with "/P" at your computer?


    PS C:\xampp> Get-Content apache_start.bat
    @echo off
    cd /D %~dp0
    echo Diese Eingabeforderung nicht waehrend des Running beenden
    echo Bitte erst bei einem gewollten Shutdown schliessen
    echo Please close this command only for Shutdown
    echo Apache 2 is starting ...


    if errorlevel 255 goto finish
    if errorlevel 1 goto error
    goto finish

    echo Apache konnte nicht gestartet werden
    echo Apache could not be started


    PS C:\xampp> Get-Content apache_start.bat | C:\Windows\System32\more.com /P
    Zu viele Angaben in der Befehlszeile. -> Translates to: Too much information in the command line.
    PS C:\xampp>

  • #112961

    Points: 403
    Helping Hand
    Rank: Contributor

    Either you translate the console output to english or you may better off in the German Powershell forum with this question. Sometimes it's easier to ask a question in your native language.
    What is it what you actually want to achieve? Powershell is able to replace cdm completely. There's actually no need anymore for "old" and pretty much obsolete cmd commands. Did you try :

    Get-Content -Path "apache_start.bat" | Out-File -FilePath "convert.txt"

    If you're not satified with the result you can try the many options (parameters) the Powershell cmdlets provide for you.

  • #112963

    Points: 0
    Rank: Member

    MORE /P should convert the Linux line feed to a typical Windows one with CR/LF.

    "type in.txt | more /p >out.txt" is the line. It worked the last time I had to edit the firmware.

    I need this to run patch scripts for a firmware under Windows that has been made for Linux. Normally the update script does this automatically with the MORE command.

    And now it just doesn't work anymore. When I call more.com in the CMD or PS, an error occurs. Probably best translated with "too many parameters..." or "too many arguments, in command line".

    I'd like to know if the command with the parameter "/P" doesn't work for you as well?

    English is no problem and the English community is much bigger.

  • #112967

    Points: 403
    Helping Hand
    Rank: Contributor

    OK. If you think it will help you to know if the command works on my machine:

    type C:\sample\data.txt | more /p > C:\sample\out1.txt
    type C:\sample\data.txt | C:\Windows\System32\more.com /p > C:\sample\out2.txt

    Both command lines wok on my machine without any error. 😉
    Windows 10 1803 , PS version 5.1.17134.228.

  • #112976

    Points: 414
    Helping Hand
    Rank: Contributor

    If you want to convert unix to windows text in powershell, this should work (running in windows):

    get-content unix.txt | set-content windows.txt

    I don't recommending using ">" or "out-file" in powershell 5. You'll end up with a file in utf-16 or "unicode" encoding.

    Hmmm? Not sure the best way to do this. Don't do it twice.

    (Get-Content -raw unix.txt) -replace "`n","`r`n" | set-content windows.txt
  • #113051

    Points: 0
    Rank: Member

    In fact, it seems to be a bug from Microsoft.
    I have several computers with the same software version.
    On some computers it runs as before and on others you have to activate the advanced functions of MORE with the /E switch to be able to use /P.

    This has probably nothing to do with the Powershell, but a forum exlizit for the command line I did not find 😉 Thanks for your thoughts.

  • #113056

    Points: 403
    Helping Hand
    Rank: Contributor

    You could give the Windows 10 General forum a try or you could think about using a pure Powershell solution.

The topic ‘"more" command broken?’ is closed to new replies.