This
ls -l /var/log | awk '{print $9}' | grep "^[a-z]*\.log."
outputs this:
alternatives.log.1
alternatives.log.10.gz
alternatives.log.2.gz
alternatives.log.3.gz
alternatives.log.4.gz
alternatives.log.5.gz
alternatives.log.6.gz
alternatives.log.7.gz
alternatives.log.8.gz
alternatives.log.9.gz
apport.log.1
apport.log.2.gz
apport.log.3.gz
but this:
ls -l /var/log | awk '{print $9}' | grep "^[a-z]+\.log."
outputs nothing.
Why? I just changed *
to +
. Isn't it similar? Operator +
just needs at least one match, and *
zero or more.