LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to tar a list of files (https://www.linuxquestions.org/questions/linux-general-1/how-to-tar-a-list-of-files-788606/)

lakshan 02-11-2010 11:17 PM

How to tar a list of files
 
Hi all,

I have some files located in /vol0/archives that has several files
Eg:- arch_00001.arc , arch_00002.arc, arch_00003.arc

I want to tar each of those files into separate tar ball by taking it garbing it from file name sequence,
Eg:- arch_00001.arc.tar.gz , arch_00002.arc.tar.gz, arch_00003.arc tar.gz

how do I define the tar command to go get those files and tar each file separately, As I mention above

Can some one help re this please


Lakshan

paulsm4 02-11-2010 11:21 PM

Something like this?
Code:

!/bin/sh

cd /vol0/archives
for i in *.arc; do
  echo "making tar of $i..."
  tar cvzf /archive_dir/${i}.tgz $i
done
echo "Done: `date`."


lakshan 02-11-2010 11:41 PM

thanks paulsm4, thanks a lot


All times are GMT -5. The time now is 12:30 PM.