Shell - noding files from the current day

Hi,

Im using this command to get some info from the files below:

> find /var/opt/smarttreee/dpa/log/event/output/TrafficErrorEvents* -type f -mtime -7 -print0 | xargs -0 grep SmartPrM | wc -l

Is there a way for it not to take the files that has the timestamp of the current day?

For example, lets say I have files like this:

TrafficErrorEvents20130917.0689
.
.
TrafficErrorEvents20130921.0689
TrafficErrorEvents20130922.0690
TrafficErrorEvents20130923.0691
TrafficErrorEvents20130923.0692
TrafficErrorEvents20130924.0693
TrafficErrorEvents20130924.0694

Using the command above Im reading the files from the day 09/24 to the 09/17  (considering today as 09/24)

So, Is there a way for it to read the files from 09/23 to 09/17 ? NOT reading the files from 09/24 ?

Tks,
Joao Telles
joaotellesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TintinCommented:
Add the -a ! -mtime 0.  Also corrected your inefficient file globbing and unnecessary use of wc

find /var/opt/smarttreee/dpa/log/event/output -name "TrafficErrorEvents*" -type f -mtime -7 -a ! -mtime 0 -print0 | xargs -0 grep -c SmartPrM 

Open in new window

0
joaotellesAuthor Commented:
Hi,

I ran the command but I have some questions:

> find /var/opt/smarttreee/dpa/log/event/output -name "TrafficErrorEvents*" -type f -mtime -7 -a ! -mtime 0 -print0 | xargs -0 grep -c SmartPrM

The output was like this:
/var/opt/smarttreee/dpa/log/event/output/TrafficErrorEvents20130918.0529:4
/var/opt/smarttreee/dpa/log/event/output/TrafficErrorEvents20130921.0633:46
/var/opt/smarttreee/dpa/log/event/output/TrafficErrorEvents20130918.0553:3
/var/opt/smarttreee/dpa/log/event/output/TrafficErrorEvents20130920.0593:40
/var/opt/smarttreee/dpa/log/event/output/TrafficErrorEvents20130923.0679:33
/var/opt/smarttreee/dpa/log/event/output/TrafficErrorEvents20130921.0626:29
.
.
.

====

But I need the total of all files, not individually like this... can it be done?


Also I noticed that it analized: 183 files.

find /var/opt/smarttrust/dpa/log/event/output -name "TrafficErrorEvents*" -type f -mtime -7 -a ! -mtime 0 -print0 | xargs -0 grep -c SmartProv_TEXTSM | wc -l
183

But I have 226 files from 09/24 to 09/18 (seven days before today)... Not sure it didnt analized all files...

Maybe your command works getting the last 24hrs instead of picking the files per timestamp?

If it works using the clock (24hrs before now).. If run it now, some files of yesterday will not be analized and this is not the goal here..

Tks,
Joao
0
TintinCommented:
Depending on your OS, you can use the -daystart flag:

   -daystart
              Measure times (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) from the beginning of today rather than from 24 hours ago.

So combing that and adding the total of all files, use:

find /var/opt/smarttreee/dpa/log/event/output -name "TrafficErrorEvents*" -type f -mtime -7 -a ! -mtime 0 | xargs cat | grep -c SmartPrm

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
skullnobrainsCommented:
if daystart is unavailable, you can always touch a file at midnight and use -newer flag (negated)

if you are using daily log rotations and a system that supports ctime, ctimes will work out-of the box
0
joaotellesAuthor Commented:
Tks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.