Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  yoonix Oct 1 '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 1 '13 at 20:39

1 Answer 1

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

C:\powershell
PS C:\netstat -an | select -first 50
share|improve this answer
    
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 '13 at 22:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.