joaotelles
asked on
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/lo g/event/ou tput/Traff icErrorEve nts* -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
Im using this command to get some info from the files below:
> find /var/opt/smarttreee/dpa/lo
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
.
.
TrafficErrorEvents20130921
TrafficErrorEvents20130922
TrafficErrorEvents20130923
TrafficErrorEvents20130923
TrafficErrorEvents20130924
TrafficErrorEvents20130924
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
ASKER
Hi,
I ran the command but I have some questions:
> find /var/opt/smarttreee/dpa/lo g/event/ou tput -name "TrafficErrorEvents*" -type f -mtime -7 -a ! -mtime 0 -print0 | xargs -0 grep -c SmartPrM
The output was like this:
/var/opt/smarttreee/dpa/lo g/event/ou tput/Traff icErrorEve nts2013091 8.0529:4
/var/opt/smarttreee/dpa/lo g/event/ou tput/Traff icErrorEve nts2013092 1.0633:46
/var/opt/smarttreee/dpa/lo g/event/ou tput/Traff icErrorEve nts2013091 8.0553:3
/var/opt/smarttreee/dpa/lo g/event/ou tput/Traff icErrorEve nts2013092 0.0593:40
/var/opt/smarttreee/dpa/lo g/event/ou tput/Traff icErrorEve nts2013092 3.0679:33
/var/opt/smarttreee/dpa/lo g/event/ou tput/Traff icErrorEve nts2013092 1.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/lo g/event/ou tput -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
I ran the command but I have some questions:
> find /var/opt/smarttreee/dpa/lo
The output was like this:
/var/opt/smarttreee/dpa/lo
/var/opt/smarttreee/dpa/lo
/var/opt/smarttreee/dpa/lo
/var/opt/smarttreee/dpa/lo
/var/opt/smarttreee/dpa/lo
/var/opt/smarttreee/dpa/lo
.
.
.
====
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/lo
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
if you are using daily log rotations and a system that supports ctime, ctimes will work out-of the box
ASKER
Tks.
Open in new window