move files older than 2 days to another folder


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers move files older than 2 days to another folder
# 1  
Old 02-10-2012
move files older than 2 days to another folder

Hi
I am facing problem in using this command,
Code:
mv `find /export/june/PURGEDATA*.txt -mtime +2 -exec ls {} \;` june/archive/

mv: Insufficient arguments (1)
Usage: mv [-f] [-i] f1 f2
       mv [-f] [-i] f1 ... fn d1
       mv [-f] [-i] d1 d2

Thank you in advance
# 2  
Old 02-10-2012
Perhaps find didn't find anything. Perhaps the usage of find is wrong?

Code:
find /export/june -name "PURGEDATA*.txt" -mtime +2 -exec mv {} june/archive \;

Code:
find ... | while read FILE; do
  mv "$FILE" june/archive/
done

# 3  
Old 02-10-2012
Try something like this:

Code:
find . -type f -mtime +2 -exec mv -v {} $directory \;

I have that in a script that runs every morning to wipe out anything older than 30 days.

**EDIT**

Woops...Scott beat me to the punch on that one, I just failed to notice that line of code...sorry.

Last edited by biomix; 02-10-2012 at 04:28 PM.. Reason: I need to re-learn to read before posting.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can i move folders and its content if folder is older than 1,5 days and keep subdirs in bash?

Hello all, do you know any way i can i move folders and its content if folder is older than 1,5 days in bash? I tried: find /home/xyz/DATA/* -type d -ctime +1.5 -exec mv "{}" /home/xyz/move_data_here/ \;All i got was that Files from DATA /home/xyz/DATA/* ended messed up in... (1 Reply)
Discussion started by: ZerO13
1 Replies

2. Shell Programming and Scripting

List files older than 10 days.

Hello all, I want to list the files older than 10 days. Currently am using find ./ -mtime +10 -exec ls -ltr {} \; command. But I want to execute the same command in 16 directories at a time and want an output asking to remove those file? Please help me to design the script. regards, Ajay (3 Replies)
Discussion started by: 02Ajay
3 Replies

3. Shell Programming and Scripting

How to move the files older than x days with similar directory structure?

Hello, I need to move all the files inside /XYZ (has multi-depth sub directories) that are older than 14 days to/ABC directory but with retaining the SAME directory structure. for example: /XYZ/1/2/3/A/b.txt should be moved as /ABC/1/2/3/A/b.txt I know about find /XYZ -type f -mtime +14... (3 Replies)
Discussion started by: prvnrk
3 Replies

4. Shell Programming and Scripting

Remove files older than 2 days.

Hi All, I am new to the scripting and using solaris 10 OS. Please suggest me from the below script which modifications need to be done to delete the files more that 2days older. Current script is deleting existing file. # Remove old explorer runs if needed DIR=`dirname ${EXP_TARGET}` if ... (2 Replies)
Discussion started by: Navkreddy
2 Replies

5. Shell Programming and Scripting

Script to delete files in a folder older than 2 days

hi i need a script to delete the files older than 2 days... if my input is say in a folder versions A_14122012.txt A_15122012.txt A_16122012.txt A_17122012.txt i want my output to be A_16122012.txt A_17122012.txt thanks in advance hemanth saikumar. (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

6. UNIX for Advanced & Expert Users

HPUX move files older than 30 days

Hello, I have a script which finds files in a directory that are older than 30 days and moves them to the specified directory. The problem is I don't know why it works the way it does? Code: find . -name '*.sql' ! -mtime -30 -exec mv '{}' /dataload/archivelogs \; I was under the... (4 Replies)
Discussion started by: pure_jax
4 Replies

7. UNIX for Dummies Questions & Answers

Files older than 50 days

Hi All, OS :- HP-UX wm5qa B.11.23 U ia64 1119805695 unlimited-user license I need to search files older than 50 days. I've used following command in order to search desired files, I also discoverd, it's showing today's files as well. Do you have any clue with this ? wmqa1> find .... (4 Replies)
Discussion started by: alok.behria
4 Replies

8. UNIX Desktop Questions & Answers

Find files older than 10 days

What command arguments I can use in unix to list files older than 10 days in my current directory, but I don't want to list the hidden files. find . -type f -mtime +15 -print will work but, it is listing all the hidden files., which I don't want. (4 Replies)
Discussion started by: Pouchie1
4 Replies

9. Shell Programming and Scripting

How to find files older than 30 days

Dear Friends, I have two queries. 1) I want to see the list of folders which were created 29 days ago. 2) I want to see the folders in which last created file is older than 29 days. Can it be done? Thank you in advance Anushree (4 Replies)
Discussion started by: anushree.a
4 Replies

10. Solaris

Copying files older then 2 days

Hi everyone :) I have a little question here, at my work, we have a system running Solaris 10 - with an attached EMC SAN, the SAN is running out of space, and we are moveing the data to a new EVA SAN. The problem here is, that there are over 35.000.000 files on the system, and constantly 30... (4 Replies)
Discussion started by: Skovsen
4 Replies
Login or Register to Ask a Question