To find files with specific dates and cp another folder.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers To find files with specific dates and cp another folder.
# 1  
Old 10-28-2008
To find files with specific dates and cp another folder.

Hi all,

We have an existing script:
find /u03/oraprod/perpcomn/admin/out -type f -ctime +7 \
-exec cp {} "/u08/oraprod/backup/cout" \;

Which is to find all files more than 7 days and copy to another folder. However I would like to only list files with Sep 29, and cp to another folder.

How can I modify to do so? Thx in advance.
# 2  
Old 10-28-2008
Code:
find /u03/oraprod/perpcomn/admin/out -type f -ctime +7 -a -mtime -8 -exec cp {} "/u08/oraprod/backup/cout" \;

I am not 100% sure if it hits your needs but you can play around with it with just a -print instead of -exec to see if it is the result you await.

-a for and
-mtime -8 to limit the time allowed

If it won't work no matter what you do, you might want to exec a ls -l and grep the date out of the long directory listing and xarg it into cp for example.
# 3  
Old 03-17-2009
Error

Please note that the full iso standard file listing is required to successfully execute the following.

Full ISO listing can be accessed via the "ls" command-line option per the following:

U**X: -E
Linux: --full

Please substitute one of the above in the code below under the variable $ISOLISTING

$SOURCEDIR and $DESTDIR should be obvious.

A little messy, but it works.
Code:
(cd $SOURCEDIR ; tar -cf -  `find . -type f -exec ls $ISOLISTING {} \; | grep 2008-09-29 | awk ' { print $9 }'` ) | (cd $DESTDIR ; tar -xpvBf -)

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

2. Red Hat

Moving files with specific dates

Hi, These are the list of files in one directory in the server : # ls -lrt total 10120 -rw-r--r-- 1 root root 4484 Jul 8 2011 install.log.syslog -rw-r--r-- 1 root root 51890 Jul 8 2011 install.log -rw------- 1 root root 3140 Jul 8 2011 anaconda-ks.cfg drwxr-xr-x 2 root root... (2 Replies)
Discussion started by: anaigini45
2 Replies

3. Shell Programming and Scripting

How to find all files other than last two dates per month and year?

Hi All, lets say there are following files in directory -rwxr-xr-x 1 user userg 1596 Mar 19 2012 a.txt -rwxr-xr-x 1 user userg 1596 Mar 19 2012 b.txt -rwxr-xr-x 1 user userg 1596 Mar 22 2012 c.txt -rwxr-xr-x 1 user userg 1596 Mar 24 2012 d.txt... (16 Replies)
Discussion started by: Makarand Dodmis
16 Replies

4. UNIX for Advanced & Expert Users

Find all files other than first two files dates & last file date for month

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (16 Replies)
Discussion started by: Makarand Dodmis
16 Replies

5. Shell Programming and Scripting

script to Find the files based on dates it came

I need a script to get the files for DEC the file format will be B20_abc_ancdfefg_20101209_INCR_201012100145.TXT.gz Based on the bold ones (date) i need to get the files can any one help me plzzzzzz (2 Replies)
Discussion started by: krux_rap
2 Replies

6. Shell Programming and Scripting

transfering files with a specific name to a folder

Hi I want to transfer all files in a folder to another folder. So the files have a ending of .lop.txt thanks (4 Replies)
Discussion started by: gisele_l
4 Replies

7. Shell Programming and Scripting

Delete files in a folder with a specific ending

Hi I have files that end with .txt.txt that i want to delete. But I also have files that end with .txt that I want to leave intact. How do I specifically delete files that end with .txt.txt in a folder. thanks (5 Replies)
Discussion started by: kylle345
5 Replies

8. Shell Programming and Scripting

Find all text files in folder and then copy to a new folder

Hi all, *I use Uwin and Cygwin emulator. I´m trying to search for all text files in the current folder (C/Files) and its sub folders using find -depth -name "*.txt" The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies

9. Shell Programming and Scripting

Parsing log files, displaying logs between specific dates

Sorry, couldn't really think of a simple subject/title. So, I have a log file, and the dates are displayed like so: 2009-03-05 02:49:44 So the first and second field are the date/time. I can change them into a unix timestamp easily with: date -d "2009-03-05 02:49:44" +%s However,... (17 Replies)
Discussion started by: Rhije
17 Replies

10. Shell Programming and Scripting

reading files for specific dates

assume files are in a directory /data $ ls -ltr Just displaying Data and file name: 01/01/2004 file_3434_typea.dat 01/01/2004 file_3423_typea.dat 01/01/2004 file_3436_typea.dat 01/01/2004 file_3434_typeb.dat 01/01/2004 file_3423_typeb.dat 01/01/2004 file_3436_typeb.dat ... (3 Replies)
Discussion started by: siva_jm
3 Replies
Login or Register to Ask a Question