## tar command with compress option...

tar command with compress option...
# 1
10-10-2002
tar command with compress option...

Hi !

i have to write a script that archivs homes not used since 3 years.
First, my script gathers the users that are concerned, using the following command :

ll -lt /home/*/.sh_history | egrep '2000|1999|1998|1997' | awk '{print $3}' i obtain a list like this : user_1 user_2 ... user_n Now i want to archiv each homes using for==>do,done with a tar (with compress option) in it.... Can someone give me the syntax i should use...i am not good at procedure writing... thx  tomapam View Public Profile for tomapam Find all posts by tomapam # 2 10-11-2002 Well, your tar command will be along the lines of: tar -czf /home/user_n /place4backup/user_n_home.tar.gz You could substitute locations or user names with variables containing those details! I'll need more time to think up the for==>do loop; I'm a bit better at Perl! I'm sure that someone here in this forum will post the for==>do loop construct for you!  WIntellect View Public Profile for WIntellect Find all posts by WIntellect # 3 10-11-2002 for loop You can redirect the output of users to a file. Then do something like this. for name in cat file.1 do echo "starting tar of"$name
tar <somthing here>
something else here
echo "tar finished for " $name done 2> error.log Just off the top of my head. A for loop is very powerful if you can use repetitive code.  Kelam_Magnus View Public Profile for Kelam_Magnus Find all posts by Kelam_Magnus # 4 10-11-2002 You can do this : #!/bin/ksh for name in ll -lt /home/*/.sh_history | egrep '2000|1999|1998|1997' | awk '{print$3}'
do
echo "starting tar of" $name tar <something here> something else here echo "tar finished for "$name
done 2> error.log

or

#!/bin/ksh
ll -lt /home/*/.sh_history | egrep '2000|1999|1998|1997' | awk '{print $3}' | while read name do echo "starting tar of"$name
tar <something here>
something else here

## tar and compress in one step

I know there is a way to tar up directory and sub-directories and have it compressed all in one command but but the syntax escapes me. I seem to re-call something like this: tar -cvf /tmp/file.tar - | compress ? Can somebody please provide me with the syntax on how to tar/compress and...

## Archive directory script with tar/compress

Hi all I need to write a script that archives all files with a certain date in the filename, to another location. It has to run on a AIX using tar/compress or another standard AIX tool. The directory will have x files, each prefixed with a date like yyyymmdd_desc.csv. I need all to...

## UNIX: Command to compress folder and all files into a tar

I am trying to grab a folder and all the folders and files underneath it and send it from one computer to another. I basically want to compress the whole folder into a tar, tgz, or zip file so that it can be sent as one file. is there a command to compress a folder and all its contents into a tar...

## Compress the file using Tar command

Hi, When i am tar the file particular ,csv file format in a folder i am receiving the error Command: tar cf New_data.tar /new/file/mari/getdata/small/*.xml Arguements too long But sometimes i am able to compress other folder but the tar folder contains all the file format and...

## compress directories with .tar extension

hi guys.. Since am a bit new to shell scripting, can anyone help me with this problem please.. i've been struggling with it since 2 days. :( I have a directory lets say myFolder and within it I have sub directories let say myFolder1.tar, myFolder2, myFolder3, etc. I need to write a shell...

## Search, Tar and Compress in one line

Hi all, I am supposed to collect a huge amount of log files from a unix system (HP-UX) onto a local system. The log files are not in one place, but they are scattered all over the Unix server. The unix server has only limited space, so that I can not create a tar file first and then compress it....

## tar and compress

I need to compress and tar a couple files in a directory, but I also want the original files unchanged, ie if I compress a1.cpp , then a1.cpp becomes a1.cpp.z, but what I want after running the compress utility is to have both a1.cpp as it is and a1.cpp.z and then tar a1.cpp.z to an...