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.
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.
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?
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
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
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.
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.
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