I am trying to write a script on SunOS that will tar up files from a set of directories. This is no problem, but what I need to do is to create 3 different archives each containing a third of the files from a particular sub-directory.
So if I have a directory structure:
masterdir
-0
--dir
---dir
----0
----1
----2
----3
-1
--dir
---dir
----0
----1
----2
----3
-2
--dir
---dir
----0
----1
----2
----3
So I have a directory with 10 subdirectories labeled 0-9 and in each one a series of subdirectories labeled 0-1000 containing a series of files.
I need to create archives with identical directory structures and each one containing approximately 1/3 of the files from each leaf directory.
Any suggestions on the best way to accomplish this?
Is the list of files stable, or might new files appear while you are processing the files you have so far?
I would try to come up with a system for dividing the files (maybe just a simple grep expression) and once you are satisified with that, feed it to | xargs tar cf -
If you have numeric file names, you could simply sort by the last digit modulo three. If the list of files doesn't change, you could even just categorize by line number within the list, but then you won't get the same files next time you run this on a set of files which is almost, but not quite identical.
Here, I suppose you could have run a find command to generate the file list -- if the list of files will not change while you are doing this, you could re-run find three times, if you want to avoid using a temporary file.
Instead of tar, you could run it with wc to see that the number of files is roughly similar for all three runs, before you proceed to actually tar them up.
There may be architectures where xargs or tar are too crippled for this, but if you can use this, it's simple and straightforward.
how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex.
so
mydemo--2015-03-23-1500.tar.gz
> database
-... (5 Replies)
hi,
Am trying to acrhive a bunch of files on some ftp site and somehow managed to come out with the below logic.
I'm getting "syntax error: unexpected end of file" error. Interestingly this below snipeet works fine if run for the first time but the subsequent runs fail!
Anybody has any idea... (3 Replies)
Hello Group,
I would request your help to build a shell script in order to find files older than 90 days then create the same directory structure under the second disk (/archive directory) and move the file preserving the same timestamps (ownership, etc).
Also keep the log of files moved... (4 Replies)
Hi,
In our current process we are reading the file, (which is placed by external vendor)from one particular folder and processing those files
through ETL(informatica). We are reading these file as " ls -ltr *.txt"
Once the process is finish these files are moved to archived script by "mv"... (1 Reply)
My requirement is to put all the files from output directory(ATT) to archive directory(archive\) creating a new
folder with datetimestamp(20100212_120014) every time it runs.
where ${IMF_TARGET_DIR} is my base directory.
${IMF_ARCHIVE_DIR} is my Archive directory... (1 Reply)
Hi,
Suppose I have 2 files of yesterday's. And today I have received 3 files.
Before processing anything I want to archieve the 2 files of yesterday's into a different folder.
How can this be done?
Regards,
Sunitha (1 Reply)
timbass
Sat, 28 Jul 2007 10:07:53 +0000
Originally posted in Yahoo! CEP-Interest
Here is my follow-up note on posets (partially ordered sets) and tosets (totally or linearly ordered sets) as background set theory for event processing, and in particular CEP and ESP.
In my last note, we... (0 Replies)
hi all i have a requirement where in i have to zip all the files with "*.bkp" after 14 days and move the zip files to Archive directory ....
i am able to achieve the first functionality but not able to achive the second one ...here is my code
find ${LOG_DIR} -name "*.bkp" -mtime +14 | xargs -i... (1 Reply)