Moving extremely large number of files to destination


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Moving extremely large number of files to destination
# 1  
Old 03-21-2009
Lightbulb Moving extremely large number of files to destination

Hello Techies,

m here with a small issue. Have read out all the relavent threads on unix.com but it was not so good sol. for me.

It's a simple & known issue. I want to move lots of files to dest folder. Actually I want to pick up 1 year older files, but that is even taking lots of time..Later on I want to archive them all.


This command is taking forever - it moved lots of files but i was bored waiting for it to comlplete all transfer (gave it 8 hrs..still in progress !)

find ./ -type f -mtime +79 -print | xargs -n1 -i mv {} /dest/


Below command returns error-

find ./ * -print | xargs -n1 -i mv {} /dest

error: Arg list too long

File name has fix pattern, based on date.
Avarage file size - 3090.
total size of files -5247124 kb.

I need to transfer them .. I dont mind with time taken - but it should give me solution..

Any help please?
# 2  
Old 03-21-2009
Go back to using your original find but with the right mtime setting. If you have lots of files, it is going to take lots of time!
# 3  
Old 03-21-2009
Hello there,

I didn't understand exactly your problem, you said
Quote:
...
but i was bored waiting for it to comlplete all transfer
and then you say

Quote:
Originally Posted by kedar.mehta
I need to transfer them .. I dont mind with time taken.
So finally time is it important or not?

Quote:
Originally Posted by kedar.mehta
Hello Techies,
...
File name has fix pattern, based on date.
....
Any help please?
If all of those files have the same pattern, can you give some examples of those file names? I think I have a script that can do the job (however not necessarily very well optimized)
Smilie
# 4  
Old 03-21-2009
Quote:
Originally Posted by kedar.mehta
Below command returns error-

find ./ * -print | xargs -n1 -i mv {} /dest

error: Arg list too long
When you use an asterisk, the shell must substitute all of the filenames prior to invoking "find". When you use -n1 on xargs, you are getting a separate mv process for each file. That will take several extra hours.

You give no clues as to what system and what shell you are using. So I assume you are using solaris 8 with ksh. The find command is outputting one file per line. Let's change that to 200 files per line. I am guessing that 200 will work. You need to experiment with your filenames to find how large you can go.


Code:
find ./ -type f -mtime +79 -print | xargs  -n200 echo | while IFS="" read NAMES ; do eval mv $NAMES /dest ; done

# 5  
Old 03-21-2009
And if your mv happens to support the -t ( --target-directory) option
you can use something like this (assuming your filenames do not contain pathological characters):

Code:
find . -type f -mtime +79 | xargs mv -t /dest

# 6  
Old 03-23-2009
compress multiple files

First of all thanks to all to provide such valuable inputs & sharing the knowledge...
Well what i did is just waited for overnight... the confusion here was 0- i didnt mind waiting for 8 hours - but in the end - it shouldn't throw me some stupid error like so many arguments,etc n waste my 8 hours of processing.

Good thing would be - if i had changed mtime into differetn categories...

Anyways now i have a different problem. I want compress all files of 2006 - old ones.

This doesnt work -
tar -cvf find ./ -type f -mtime +1176 -print

After lots of processing - it gives me error - no such file exists..

How to get this done.. ? I got gzip as well ..but i want it to process multiple files....

Btway, how do i know - what is server O/S on which i am working ? Unix environment related info...Lots
of basic questions here!! Smilie
Once again, thanks !

Last edited by kedar.mehta; 03-23-2009 at 12:55 AM..
# 7  
Old 03-23-2009
Basics to state your environment.

Code:
# Operating system
uname -a
# Shell
echo ${SHELL}

How many files do you have to move and archive? I make it about 1.7 million files based on your stated average file size (assuming your 3090 is in bytes) and total size of 5 Gb.
# To count the files which match your condition
find <condition> -print | wc -l

Are all these files in the same source directory?
Are there subdirectories under your source directory?
Is the source directory and the destination directory under the same mountpoint?
Do any of the filenames contain space characters or other awkward characters such as asterisk?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count the number of files copied from source to destination location

Hi Guys, how to count number of files successfully copied while coping files from source to destination path ex:10 files from source to target location copying if 8 files copied successfully then echo successfully copied=8 failure=2 files if two files get error to coping files from... (23 Replies)
Discussion started by: sravanreddy
23 Replies

2. Shell Programming and Scripting

Sftp large number of files

Want to sftp large number of files ... approx 150 files will come to server every minute. (AIX box) Also need make sure file has been sftped successfully... Please let me know : 1. What is the best / faster way to transfer files? 2. should I use batch option -b so that connectivity will be... (3 Replies)
Discussion started by: vegasluxor
3 Replies

3. Shell Programming and Scripting

Moving and renaming large ammount of files

Hey, I'm kinda new to the shell scripting and I don't wanna mess things up yet :) Looking for a solution to the following: I need to move all the files like "filename.failed.dateandtime" to another directory also renaming them "filename.ready". I can't figure how to do this with multiple files... (4 Replies)
Discussion started by: sg3
4 Replies

4. UNIX for Dummies Questions & Answers

Moving Multiple files to destination files

I am running a code like this foreach list ($tmp) mv *_${list}.txt ${chart}_${list}.txt #mv: when moving multiple files, last argument must be a directory mv *_${list}.doc ${chart}_${list}.doc #mv: when moving multiple files, last argument must be a... (3 Replies)
Discussion started by: animesharma
3 Replies

5. Programming

Working with extremely large numbers in C

Hi All, I am just curious, not programming anything of my own. I know there are libraries like gmp which does all such things. But I really need to know HOW they do all such things i.e. working with extremely large unimaginable numbers which are beyond the integer limit. They can do add,... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

6. UNIX for Dummies Questions & Answers

Delete large number of files

Hi. I need to delete a large number of files listed in a txt file. There are over 90000 files in the list. Some of the directory names and some of the file names do have spaces in them. In the file, each line is a full path to a file: /path/to/the files/file1 /path/to/some other/files/file 2... (4 Replies)
Discussion started by: inakajin
4 Replies

7. Shell Programming and Scripting

Concatenation of a large number of files

Hellow i have a large number of files that i want to concatenate to one. these files start with the word 'VOICE_' for example VOICE_0000000000 VOICE_1223o23u0 VOICE_934934927349 I use the following code: cat /ODS/prepaid/CDR_FLOW/MEDIATION/VOICE_* >> /ODS/prepaid/CDR_FLOW/WORK/VOICE ... (10 Replies)
Discussion started by: chriss_58
10 Replies

8. UNIX for Dummies Questions & Answers

questing regarding tar large number of files

I want to tar large number of files about 150k. i am using the find command as below to create a file with all file names. & then trying to use the tar -I command as below. # find . -type f -name "gpi*" > include-file # tar -I include-file -cvf newfile.tar This i got from one of the posts... (2 Replies)
Discussion started by: crux123
2 Replies

9. Shell Programming and Scripting

Script to Compare a large number of files.

I have a large Filesystem on an AIX server and another one on a Red Hat box. I have syncd the two filesystems using rsysnc. What Im looking for is a script that would compare to the two filesystems to make sure the bits match up and the number of files match up. its around 2.8 million... (5 Replies)
Discussion started by: zippdawg2001
5 Replies

10. Shell Programming and Scripting

moving large number of files

I have a task to move more than 35000 files every two hours, from the same directory to another directory based on a file that has the list of filenames I tried the following logics (1) find . -name \*.dat > list for i in `cat list` do mv $i test/ done (2) cat list|xargs -i mv "{}"... (7 Replies)
Discussion started by: bryan
7 Replies
Login or Register to Ask a Question