Bash shell - AWK print text file removing first two blank lines that contain \n

Posted on 2006-03-30
Last Modified: 2012-05-05
I have a text file with some information that im trying to process. I want to remove the first two blank lines that only have \n
on them, but I need to keep the rest of the lines below that with their respective \n characters. How would I use AWK to read
the file, remove the first two lines and leave the rest alone without removing their newlines?

Thanks in advance!
Question by:cybrthug
    LVL 51

    Accepted Solution

    awk '(p<2){if(NF==0){p++;next;}}{print}' file

    Author Comment

    Thank you sir, excellent.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
    When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Video by: Phil
    This video goes over how to configure and start a jail in FreeBSD.  This video is meant to supplement the article included with this course.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now