Windows equivalent of the 'tail' command

前端 未结 21 3056
长情又很酷
长情又很酷 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:42

    Well, this will do it, but it's about as fast as it looks (roughly O(n*m), where n is the number of lines to display and m is the total number of lines in the file):

    for /l %l in (1,1,10) do @for /f "tokens=1,2* delims=:" %a in ('findstr /n /r "^" filename ^| findstr /r "^%l:"') do @echo %b
    

    Where "10" is the number of lines you want to print, and "filename" is the name of the file.

提交回复
热议问题