My goal is to display a list of log names, from the start time column, grepping for 20161221
. I use this command:
$ ls -m1 /var/log/audit.raw.* | grep 20161221
/var/log/audit.raw.20161220173001EST.20161221000004EST.gz
/var/log/audit.raw.20161221000004EST.20161221083001EST.gz
/var/log/audit.raw.20161221083001EST.20161221163000EST.gz
/var/log/audit.raw.20161221163000EST.20161222000004EST.gz
But the first entry is from 20161220
. I know I can trim it successfully with this command instead:
$ ls -m1 /var/log/audit.raw.* | grep 20161221 | tail -n +2
/var/log/audit.raw.20161221000004EST.20161221083001EST.gz
/var/log/audit.raw.20161221083001EST.20161221163000EST.gz
/var/log/audit.raw.20161221163000EST.20161222000004EST.gz
I wanted to see if there is a more intelligent use of grep to avoid trimming the output with tail -n +2