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.

taha
  • 1
  • 1
  • 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](http://stackoverflow.com/questions/1295068/windows-equiv-of-the-head-command). There are several suggestions listed there. –  Oct 01 '13 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 01 '13 at 20:39

1 Answers1

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
JHill
  • 156
  • 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 01 '13 at 22:23