0

I need to display the first 50 lines of the output of a command (any command). In other words, I essentially want an equivalent of the Unix "head" command.

but I dont have permission to create file using the command :

C:> netstat -an > temp.txt && for /l %l in (1,1,10) do @for /f "tokens=1,2* delims=:" %a in ('findstr /n /r "^" temp.txt ^| findstr /r "^%l:"') do @echo %b

Since the command executes on a remote server it does not allow creation of files, please help me change this command to pipe with another command.

I am working on a getting a list of only 50 files that have a specific file name pattern e.g. taha_12345_T_T_00987.txt from a specific folder.

2
  • I don't have an answer for you, but my first google search popped this up as the first hit: Windows equiv of the 'head' command. There are several suggestions listed there.
    – user143703
    Oct 1, 2013 at 19:58
  • Thanks yoonix, my question is inspired from the question in that link, i need a more specific anwer to my question.
    – taha
    Oct 1, 2013 at 20:39

1 Answer 1

2

Do you have access to PowerShell? It is usually available starting with XP/Server 2003.

C:\powershell
PS C:\netstat -an | select -first 50
1
  • it is a leagcy application which requires changes, I cannot choose powershell over dos commands , I just need to filter the list to only 50 files at a time from a folder that may contain hundreds of files that is causing the script to stall/hang and does not even respond with an error message.
    – taha
    Oct 1, 2013 at 22:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .