The -n
statement checks if the string is empty:
while read line do if [ -n "$line" ] echo $line fi done < file.txt
If you want to exclude lines containing only white space characters, you can use bash template replacement ${var//find/replacement}
. For instance:
if -n [ "${line//[[:space:]]/}" ]
source share