If the file has special properties that you're looking for then grep is a useful tool
otherwise I guess a bunch of if's and stuff is needed, but it's doable in a one liner
print_it=0; for i in $(cat test.txt|sed -e "s/^\(.*\)$/\"\1\"/"); do i=$(echo $i|sed -e "s/^\"\(.*\)\"/\1/"); [ $print_it -eq 1 ] && echo $i && print_it=0; print=$(echo $i|grep "^$" > /dev/null; echo $?); [ $print -eq 0 ] && print_it=1; done
To clarify it i'll split it up like a script
# Just setting this to avoid a -eq unary operator error.
# Loop throu the text file. Since there's nasty whitespaces in this file we encase all the lines with quotation.
# Change test.txt to the file name.
for i in $(cat test.txt|sed -e "s/^\(.*\)$/\"\1\"/"); do
# And now we remove it for this particular itteration
i=$(echo $i|sed -e "s/^\"\(.*\)\"/\1/")
# Check if the previous spin yielded a "blank" row
if [ $print_it -eq 1 ];then
# If it did, print the line and reset the variable.
# Get status code for the content of the current row to see if it's a blank or not.
print=$(echo $i|grep "^$" > /dev/null; echo $?)
# If it was a blank we set the variable for the next itteration
if [ $print -eq 0 ]; then
sajko@hanna:~> sh test.sh
from a file looking like this:
If the file has a special formatting it's probably easier to check for occurrences, but since you only supplied that the file contains blank rows and then the actual thing you're looking for is this is the best I can do.
Hope this gives you a clue anyway