I try to print lines of a text which begin with a # I need only these lines, but not the ones with [[:whitespace:]]#
$ cat text.txt
# no whitespace in front of #
# 3 whitespace in front of #
# tab in front of #
$ cat text.sh
#!/bin/bash
TEXT=text.txt
Sub=2 # required for the case-statement I have to perform in the real script
while read LINE ; do
case $Sub:$LINE in
2:"# "*) printf "%s\n" "$LINE" ;;
esac
done < "$TEXT"
$ ./text.sh
# no whitespace in front of #
# 3 whitespace in front of # <<< the 3 whitespaces are gone
# tab in front of # <<< the tab is also gone