batching files

HI,

Suppose I have thousand files in one directory and they can keep increasing ie
/home/rooh

Then I want to create a batch of 100 files and then compress that batch file and ftp them somewhere else. And morever the files in the batch will be moved to somewhere else.

Can you please help me as to how I can create a batch of these files.

Thanks.
Rooh:(

Hallo rooh.
What did you exactly mean ?
A tar or zip file with 100 files inside ?
Please describe your problem more concrete.
regards joerg

Hi Jeorg,

Basically my problem is that I have a files in a directory and they will keep increasing as i want to do this . So can't just split the files.

Moreover I want to create a batch of 100 files and then also move this batch to another place.

I can move then , that easy , to a new directory but my problem is how do I create a batch file which will contain these 100 files.

Once I am able to create a batch file , I will BE able to ZIP & TAR THEM.

But my main problem is how do I create a batch file which will contain all these 100 files.

Hope this makes a bit clear.
Your quick assistance will be highly appreciated.

Thanks.
R:cool: :cool: h

Sorry,
but at the moment I am no sure that my answer can help you.
However try this.

make a compressed file to send it to an other host.
tar xvf /file.tar /home/100_files_dir/*
gzip file.tar

send it to an other host per ftp.

unzip & untar it to a folder.
gzip -d ./file.tar.gz
tar xvf ./file.tar

For me a bach file is something to execute commands!

If this is not this kind of information you need, then excuse my for my fail interpretation of the englich language.
regards joerg

Hi ,

i AM SORRY , but that's not what I want.

Basically what I am looking for is:

Suppose I have a directory /home/rooh
I have for eg these files:
-rw-r--r-- 1 hyun arboradm 6748 Mar 20 09:34 ROOH0039032009241204
-rw-r--r-- 1 hyun arboradm 4466 Mar 20 09:34 ROOH0039032009241203
-rw-r--r-- 1 hyun arboradm 4466 Mar 20 09:31

Now I want to create a file and copy these files to a file RRO_2198.

How can I do this ??????:confused:

Is this somthing you want done on a regular basis?

I'll do this once a month.

But can someone kindly tell me if I can copy these files to a file ????

OK, I may also not get what you're saying, but here goes:
Are all of those files text?
And you want to create one large text file?

If so, you could do something like this:

[...]
for each in /home/rooh/ROOH*
do
cat $each >> RRO_2198
rm $each
done
[...]

You should test this first, though, before including the rm command in there...

You did mention using zip and tar, above, though. Do you want to create a tar archive?
tar cf RRO_2198.tar /home/rooh/ROOH*
zip RRO_2198.tar

Then use ftp / email / scp / etc... to move them off the box, or mv to move it around the box...

Please be more clear if this is not correct instead of simply repeating your previous posts. Maybe try asking the question using different words or analogies?

Hi,

Looks like I am unable to explain my problem.
LivinFree, I used your script for testing but that doesn't help because when I do cat $each , it will copy the contents of the file,but not the complete file with its name ,and as it is.

Basically this is what i want.

Suppose I have a directory
/home/ROOH

It contains files
-rw-r--r-- 1 rooh aradm 6748 Mar 20 09:34 ROOH0039032009241204
-rw-r--r-- 1 rooh aradm 4466 Mar 20 09:34 ROOH0039032009241203
-rw-r--r-- 1 hyun aradm 4466 Mar 20 09:31
ROOH0032567890098879

and so on.......

what I want is basically a file which should contain these files as they are.

Suppose a file ROOH01
it should contain the files like

-rw-r--r-- 1 rooh aradm 6748 Mar 20 09:34 ROOH0039032009241204
-rw-r--r-- 1 rooh aradm 4466 Mar 20 09:34 ROOH0039032009241203
-rw-r--r-- 1 hyun aradm 4466 Mar 20 09:31
ROOH0032567890098879

So basically this is what I want.

Hope I am clear this time.

Thanx
Rooh

i really dont think what your trying to do can be done the way you want it to be done.

if there are other files in the directory along with the wanted "files", i would suggest you try creating a new directory and then moving only those wanted files into that directory. then backup the directory itself by using, (tar, cpio, dd). see if that helps at all

Hi ,
Thanx for ur responce.
Your idea seems to be great , can I ask for one more favour.

Can you tell me how I can create a backup.

It sounds great that I have a new_irectory and first move all my wanted files into the new directory.

But can you tell me how I can create the backup of this.

Your help will be highly appreciated.

Thanx alot of the good suggestion .

Rooh

after you have created a new directory and moved all the wanted files in there, then:

you should use tar cvf (output file) (absolute path of the new directory to backup)

output file = name of the file you want the directory to be backed up in to (make up any name)

absolute path of the new directory to backup = the complete path to where the newly created directory is located at

say I want to back up a directory named new_directory into a one file called directory_backup

i do this

tar -cvf directory_backup new_directory
(note: you have to specify the absolute path of the directory you want to backup)

later, if you wanna extract the files or any file from the backup tar achieve you just created, you simply type:

tar -xvf (directory_backup) (new_directory/whatever files you want to retrieve or extract)

again, directory_backup here means the file you backed up the directory into
new_directory means the path to the directory you want to backup

Let me know if your satisfied with the results

That seems to work great . Thanx alot for sharing your expertise.

Can i trouble you any further.
One more question ?

Is it possible to do something like this with cpio.
If yes How ????

Thanks.
Rooh

if you want to use cpio, this is what you do:

you cd into the newly created directory containing only those files you want.

then you type this:

ls | cpio -oO (name of backupfile)

say I want to backup those files I want into a file called smart.cpio, this is what I do

ls | cpio -oO smart.cpio

if i want to extract all files from smart.cpio, I will type:

cpio -itI smart.cpio

that should help you out

Hi,

Thanx UNIX Guru, u are just too good.

One more question ?

Does Cpio actually copies all the desired files to the new file.
How does it actually work.

I have gone thru the man pages , but wasn't of much help.

Thanx in advance
Rooh

Hi,

When I used the cpio option , it actually didn't help me much.
I first cahnged to the directory which contains the new moved files
and then I used the command provided by you.

It gave me an Error Message:

/home/arbor>ls | cpio -oO /tmp/R00HAA.cpio
cpio: illegal option -- O
Usage: cpio -o[aAcBvxCh] [-e warn|force|ignore] <name-list >collection
cpio -i[BcdmPrtuvfsSbx6RU] [pattern ...] <collection
cpio -p[adlmruvxU] [-e warn|force|ignore] directory <name-list

Please let me know if I am going wrong somewhere.

Thanx
Rooh

First of all, when it comes to learning commands, only use the man pages if you cant find the definition somewhere else in a unix book. I personally dont use man pages unless I have to. man pages certainly is not the easiest thing to understand. I never refer nobody to a man page unless I checked it out my self and found it to be very helpful. try spending time online looking for definitions if you cant get a hold of a book

anyway, about that cpio thing. did you type a small letter o and a big letter O or did you mistakenly type number 0???

these characters look quite similar so be careful.

get in the directory where your wanted files are in and try this command:

ls | cpio -o > (name of file you want to back it up in)

to extract the files, do: cpio -i (name of file you backed up your files in)

that should work, if it dont then use tar instead.

if my linux pc was connected to the internet, I'd be a lot helpful to you but I goto reboot to access my linux system.

Thanx for all your help and suggestions.

I think I cannot have a better Guru than you.

Can you please suggest me the efficient way of doing my task.

Basically I have got all my Files in my directory, Right .
Then I want them to be in a particular file ( You suggested I use tar).

Now I want to ftp across to some other server , OK ?

And that server just has the utility of GZIP. so Looks to me like then this won't work.

Basically what I want is put all my files in a single file and then Gzip that file and send it across by ftp.

Can you suggest me how this task is possible ?????

Your help & suggestions will be highly appreciated.
Thanx
Rooh

What operating system are you using?? I dont know much about other operating systems except for Linux and little knowledge of solaris

anyway, I would suggest you use the tar method I showed you earlier. When you have already backed up the wanted files to a file, then you simply do this:

type: gzip (the file containing the wanted files)
type: ls
look for the file name you just gzipped and it should have a .gz attached to it

through ftp, log onto the server and go to the specific directory or place you want to transfer the file onto.

type: put (name of the gzipped file that has .gz attached to it)

that should do it

and by the way, using tar will certainly work with gzip and also, I hope you know your way around the ftp system cause that sure would help you deliver the file safely to where you want it delivered. are you familiar with the ftp commands??? if not, when you type ftp at the command prompt, you get a prompt that looks like this ftp>

now, you can type help at the ftp prompt and that will help you with the commands you need to accomplish what you want

ftp> help

Hi ,
Thanx alot.

Now One more question .

When I had tared the files , and later wanted to extract them it shows me the complete pathname , something like this

x /home/R00h_ph_files/PH_TEST/PH0030012301544700000AF-005, 13950 bytes, 28 tape blocks
x /home/R00h_ph_files/PH_TEST/PH0030012301544700000AF-006, 15023 bytes, 30 tape blocks
x /home/R00h_ph_files/PH_TEST/PH0030012301544700000AF-007, 13272 bytes, 26 tape blocks

Is it possible that it just shows the names of the file rather than the whole path.

I could see the same thing even when the files were archived.
Why does it show the complete path of the file from where it is archived.

Thanx.