PDA

View Full Version : how to .tar.gz for more than one file in single attempt.



tushar.hiwse
November 30th, 2009, 04:07 AM
Hi Guys,

Thanks in advance !!

Actually, I want to list 10 big size files from directory (say /logs) and do the .tar.gz in single attempt on Redhat Linux, AIX and Solaris.


Regards,
Tushar

:popcorn:

Barriehie
November 30th, 2009, 05:10 AM
Hi Guys,

Thanks in advance !!

Actually, I want to list 10 big size files from directory (say /logs) and do the .tar.gz in single attempt on Redhat Linux, AIX and Solaris.


Regards,
Tushar

:popcorn:

Do you mean to make a .tgz file from 10 files only in a specific directory? Like
tar -cvpzf somefilename.tgz file1 file2 file3 ...

Barrie

tushar.hiwse
November 30th, 2009, 06:46 AM
But, By using abovesaid command it will create complete .tgz file for 10 big files. I have to create .tgz file for each one in a single shot.

M4rotku
November 30th, 2009, 06:52 AM
just do one file, using the example above but with only one file, then put an & symbol, and then type the same thing for the next file, then another & symbol and so on. Easiest way that I can think of.

tushar.hiwse
November 30th, 2009, 06:57 AM
Hi M4rotku,

Is there any another way for that ?
Can u give me it in command ?

Rinzwind
November 30th, 2009, 06:59 AM
You can do that with a bash script:


#!/bin/bash
for i in $( ls ); do
echo item: $i
done


Change the "ls" to search for the files you need.
Change the "echo item: $i" to a tar command.