Count number of specific character per line (our example number of tabulation)

cat file | tr -d -c '\t\n'| awk '{ print length; }'> stat

Extract strings that match a regular expression (our case string that begin with XXX and contain 9 characters)

cat input | egrep -oh 'XXX......' > output