1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Rep Power

    Keep top 5 lines from a file and the same file name

    Here is what I want to do...

    I have a bunch of text files that I need to go through and keep only the top 5 lines. I need the file name to be the same as it was earlier.

    Ex.: file.name - take top 5 lines (delete everything below line 5), then save file as file.name. There are a number of files that this will need to be done on as a batch.

    I know this can be done in linux, but I only have windows available, but it does have perl, yet I am not a perl guy... at all.

    Any help would be appreciated.

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Paris area, France
    Rep Power
    Cygwin gives you a Linux environment on a Windows platform...

    But, surely enough, it can be done in Perl and I could do it in a few lines of code. However this forum is not a place for people to get free code without making any effort. Show what you tried, and we will help you on the difficulties you are encountering. We will be glad to help you. But don't ask us to to your work (or home work) for you.

IMN logo majestic logo threadwatch logo seochat tools logo