If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > extracting files arrivng today and those arrived y'day

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-04-06, 12:24
pavan_test pavan_test is offline
Registered User
 
Join Date: Oct 2005
Posts: 45
extracting files arrivng today and those arrived y'day

Hi All.,

1 ssssss C2052EX 15 Mar 30 19:01
1 aaaaa C2052EX 15 Apr 3 10:12
1 ccccc C2052EX 15 Apr 4 09:28


i have files arriving like above.
i am using the following to extract files arriving today ( say apr4)


todaydat=`date | cut -c5-10`
find DIR_PATH/START.*.*.*.ctl* -exec ls -ltr {} \; -mmin +200 | grep
"$todaydat" | awk -F" " {'print $9'}


now i am trying to extract files arriving today ( say apr 4) and those arrived y'day ( say apr 3)
can anyone please give me any suggestions.


thanks
pavi
Reply With Quote
  #2 (permalink)  
Old 04-04-06, 13:53
Bob4480 Bob4480 is offline
Registered User
 
Join Date: Feb 2004
Location: Los Angeles, CA
Posts: 28
Try the mtime argument

Use the -mtime (Modified Time) argument in the find statement.

Code:
 todaydat=`date | cut -c5-10` 
find DIR_PATH/START.*.*.*.ctl* -mtime 1 -exec ls -ltr {} \; -mmin +200 | grep 
"$todaydat" | awk -F" " {'print $9'}
1 = Yesterday, 2 the day before etc...
+1 = all days yesterday and before.
Reply With Quote
  #3 (permalink)  
Old 04-04-06, 14:03
pavan_test pavan_test is offline
Registered User
 
Join Date: Oct 2005
Posts: 45
extracting files arrived today and yesterday

can you please give me the mtime arguement..

thanks
pavi
Reply With Quote
  #4 (permalink)  
Old 04-04-06, 14:18
pavan_test pavan_test is offline
Registered User
 
Join Date: Oct 2005
Posts: 45
extracting files arrived today and yesterday

Hello.,

i am doing this;

todaydat=`date | cut -c5-10`

find DIR_PATH/START.*.*.*.ctl* -exec ls -ltr {} \; -mtime -2 -mmin +200 | grep "$todaydat" | awk -F" " {'print $9'}

This is giving me only the files arrived today ( Apr 4) but i am also looking for files arrived Apr 4 and Apr 3rd.

can you please suggest me;

thanks
pavi
Reply With Quote
  #5 (permalink)  
Old 04-04-06, 15:28
pavan_test pavan_test is offline
Registered User
 
Join Date: Oct 2005
Posts: 45
extracting files arrived today and yesterday

Hello

i am using these ( from man pages in Unix)
yesterdaydat=date -d "yesterday" | cut -c5-10
Apr 3

todaydat=date | cut -c5-10
Apr 4

now i am trying to use the output of both the above commands to extract the files arrived today and yesterday. can you please give me a suggestion;

find DIR_PATH/START.*.*.*.ctl* -exec ls -ltr {} \; -mmin +200 | grep
"$todaydat" | awk -F" " {'print $9'}

thanks a bunch
pavi
Reply With Quote
  #6 (permalink)  
Old 04-05-06, 05:01
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
mtime -2
will find last 48 hours which could include the day before yesterday e.g.
Code:
# ls -l
total 5
drwxr-xr-x   2 root root 288 Apr  5 10:34 .
drwxrwxrwt  20 root root 864 Apr  5 10:31 ..
-rw-r--r--   1 root root   0 Apr  3 03:59 f0
-rw-r--r--   1 root root   0 Apr  3 23:09 f1
-rw-r--r--   1 root root   0 Apr  3 23:59 f2
-rw-r--r--   1 root root   0 Apr  4 00:00 f3
-rw-r--r--   1 root root   0 Apr  4 12:00 f4
-rw-r--r--   1 root root   0 Apr  4 23:59 f5
-rw-r--r--   1 root root   0 Apr  5 00:00 f6
-rw-r--r--   1 root root   0 Apr  5 03:59 f7
-rw-r--r--   1 root root   0 Apr  5 10:20 f8
-rwxr-xr-x   1 root root 224 Apr  5 10:29 t1
# date
Wed Apr  5 10:48:12 SAST 2006
# find . -mtime -2 -mmin +200 -ls
150012    0 -rw-r--r--   1 root     root            0 Apr  3 23:09 ./f1
150054    0 -rw-r--r--   1 root     root            0 Apr  3 23:59 ./f2
150062    0 -rw-r--r--   1 root     root            0 Apr  4 00:00 ./f3
171447    0 -rw-r--r--   1 root     root            0 Apr  4 12:00 ./f4
171448    0 -rw-r--r--   1 root     root            0 Apr  4 23:59 ./f5
171449    0 -rw-r--r--   1 root     root            0 Apr  5 00:00 ./f6
171456    0 -rw-r--r--   1 root     root            0 Apr  5 03:59 ./f7
Try this instead (and you don't need grep "$todaydat")
Code:
# touch -t 200604032359.59 /tmp/reffile.$$
# find . -newer /tmp/reffile.$$ -mmin +200 -exec echo {} \;
./f3
./f4
./f5
./f6
./f7
# rm /tmp/reffile.$$
OR
Code:
# yd=$(date -d "yesterday"|cut -c 5-10)
# td=$(date |cut -c 5-10)
# find . -mtime -2 -mmin +200 -ls | egrep "$yd|$td" | awk '{print $11}'
./f3
./f4
./f5
./f6
./f7
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On