move all 2008 year's file to destination directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers move all 2008 year's file to destination directory
# 1  
Old 02-19-2009
move all 2008 year's file to destination directory

I am trying to move file created/modified in 2008 year to <new directory>. But trapped badly in Xargs {}.

Looks like mv is not getting destination file properly. It assumes source file s to be destination directory n gives me erroir. "Target must be a directory"

Run-
#/home/mktrisk: find ./ -type f -mtime +50 -print | xargs mv /mrk_archive/PG/ftp/data/asia/SI/2008/
Error-
mv: Target ./<Sourcefile> must be a directory


I tried with {} too, but no help.

This was failed too, -
#/home/mktrisk: find ./ -type f -mtime +50 -print | xargs mv {} /mrk_archive/PG/ftp/data/asia/SI/2008/

Same error..

Any help....

Thanks,in ad
# 2  
Old 02-19-2009
Try this:

Code:
#/home/mktrisk: find ./ -type f -mtime +50 -print | xargs -n1 -i mv {} /mrk_archive/PG/ftp/data/asia/SI/2008/

# 3  
Old 02-20-2009
moving multiple files

Well, this seems to be working... Thanks buddy.

However, I am still not clear about how to use {} with Xargs. Can't I do the same thing without {} ?

& what difference "-n1 -i mv {}" will make ? -i : I dont need interactive. -Does -n1 mean one argument at a time?

Is it really necessary to pass only one param, with interactive movement?
# 4  
Old 02-21-2009
-i is not interactive... more like insert. It means replace {} with the result coming from the find command.
-n1 means one argument at a time exactly. It should work without -n1 but i dont know if you can have problem if the number of files found is really large.
# 5  
Old 03-23-2009
Cool, Thanks buddy..!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. UNIX for Dummies Questions & Answers

How to move gz files from one source directory to destination directory?

Hi All, Daily i am doing the house keeping in one of my server and manually moving the files which were older than 90 days and moving to destination folder. using the find command . Could you please assist me how to put the automation using the shell script . ... (11 Replies)
Discussion started by: venkat918
11 Replies

3. UNIX for Dummies Questions & Answers

How to create a TAR File in a Custom Destination Directory?

I want to create the tarzip file into a destination directory, i am in /var/sftp/home/archive/rquadri directory and i am using below command. However it is creating the file in the /var/sftp/home/archive/rquadri directory itself instead of /tmp, may i please know how do i resolve this. tar -cvzf... (5 Replies)
Discussion started by: Ariean
5 Replies

4. Shell Programming and Scripting

How to find the one file and move destination using scripts in AIX?

I have run the one scripts the scripts is provide the two different format of output.How to getting the output. (2 Replies)
Discussion started by: rajivgandhi
2 Replies

5. Shell Programming and Scripting

How to find the one file and move destination using scripts in AIX?

I have a script which has two output formats in which i'am getting the two different output format in str1 and str2.So i want to get the output if the format is like str1 then i have to copy that into a directory or str2 format means it should be moved.This script i'am executing in shell script... (4 Replies)
Discussion started by: rajivgandhi
4 Replies

6. Shell Programming and Scripting

find + move if destination path does not exist

hi frnds, please help ... what will happen with below command if destination path does not exist on the system.... find /var/adm/cft* -mtime +1 -exec mv {} /global/ \ in unix its remove all my files from the system from soruce file ... how is it possbile (1 Reply)
Discussion started by: dodasajan
1 Replies

7. Shell Programming and Scripting

Move all files from source to destination directory based on the filename

Move all files starting with a specific name to different directory. This shell script program should have three parameters File Name Source Directory Destination Directory User should be able to enter ‘AB_CD*' in file name parameter. In this case all the files starting with AB_CD will... (1 Reply)
Discussion started by: chetancrsp18
1 Replies

8. Red Hat

Move files of a certain year to other directory

Hi all, I have a massive amount of recording files in .WAV format stored in a directory, files dating back to 2006. It is a huge amount of files as Linux cannot even do a listing of it all, it states: "argument list too long" What I would like to do is the following: Find all the files of... (6 Replies)
Discussion started by: codenjanod
6 Replies

9. Shell Programming and Scripting

move file by year/mouth

Hello experts, I have a directory which the files inside have different date. Now I'd like to move them to folder year/mouth (2007/01 , 2007/02) Have any suggestion? thanks in advance for reading or anyposts. (3 Replies)
Discussion started by: mmm951
3 Replies

10. UNIX for Dummies Questions & Answers

calculate directory size by year of file

I need to calcualte the size of a directory by the year the files in that directory were created . For example the script will sum up, by year, the number of blocks for that directory and its' subdirectories for files created / accessed in that year. I need a report that would look like... (11 Replies)
Discussion started by: igidttam
11 Replies
Login or Register to Ask a Question