Windows equivalent of the 'tail' command

前端 未结 21 2949
长情又很酷
长情又很酷 2020-11-28 01:48

Is there a way to simulate the *nix tail command on the Windows command line? I have a file and I want a way to snip off the first n lines of text. For example:

相关标签:
21条回答
  • 2020-11-28 02:49

    As a contemporary answer, if running Windows 10 you can use the "Linux Subsystem for Windows".

    https://docs.microsoft.com/en-us/windows/wsl/install-win10

    This will allow you to run native linux commands from within windows and thus run tail exactly how you would in linux.

    0 讨论(0)
  • 2020-11-28 02:50

    I don't think there is way out of the box. There is no such command in DOS and batch files are far to limited to simulate it (without major pain).

    0 讨论(0)
  • 2020-11-28 02:51

    in PS try to use command:

    Select -Last 1
    

    This command can be pipelined also.

    Example to get first line:

    type .\out.txt | Select -Last 1
    

    or to get the first line:

     type .\out.txt | Select -First 1
    
    0 讨论(0)
提交回复
热议问题