Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

Echo File Until a Blank Line Is Reached

May 27, 2023 — Gregg Szumowski

You can use the awk program to search and print lines in a file. If you wanted to print a file until the first blank line is reached you can use the following command to do that:

awk '$0 ~ /^$/ {exit;} {print $0;}' somefile.txt

Tags: awk, cli, motd