[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2335
  • Last Modified:

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

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!
1 Solution
awk '(p<2){if(NF==0){p++;next;}}{print}' file
cybrthugAuthor Commented:
Thank you sir, excellent.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now