none
Read a text file from the bottom up RRS feed

Answers

  • JRV, will do. Thanks.

    Mjolinor, file could have thousands of lines in it.

    Just trying to figure out the best way to read a text file from the bottom up. Any suggestions? I can try the above method of "..1" and see how it works for me, but didn't know if there was a better method available?

    If I wanted to read a file into an array and then reverse it, I'd do this:

    $file = gc "C:\users\$env:username\Desktop\test.txt"
    [array]::reverse($file)
    $file


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    • Marked as answer by KentYeabower Wednesday, March 11, 2015 6:44 PM
    Wednesday, March 11, 2015 4:06 PM

All replies

  • help about_operators

    Learn to use help.  It will save you tons of time.


    ¯\_(ツ)_/¯

    Wednesday, March 11, 2015 2:07 PM
    Moderator
  • That depends on what you mean by "large".  

    It's reading the whole file into memory, which can result in memory exhaustion and possibly Out of Memory exceptions, depending on the size of the file and the available resources.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Wednesday, March 11, 2015 2:08 PM
  • JRV, will do. Thanks.

    Mjolinor, file could have thousands of lines in it.

    Just trying to figure out the best way to read a text file from the bottom up. Any suggestions? I can try the above method of "..1" and see how it works for me, but didn't know if there was a better method available?

    Wednesday, March 11, 2015 4:01 PM
  • JRV, will do. Thanks.

    Mjolinor, file could have thousands of lines in it.

    Just trying to figure out the best way to read a text file from the bottom up. Any suggestions? I can try the above method of "..1" and see how it works for me, but didn't know if there was a better method available?

    If I wanted to read a file into an array and then reverse it, I'd do this:

    $file = gc "C:\users\$env:username\Desktop\test.txt"
    [array]::reverse($file)
    $file


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    • Marked as answer by KentYeabower Wednesday, March 11, 2015 6:44 PM
    Wednesday, March 11, 2015 4:06 PM
  • Thanks mjolinor! That worked great.
    Wednesday, March 11, 2015 6:44 PM