The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Copy Compress as one command findprakash UNIX for Dummies Questions & Answers 10 03-08-2009 01:19 PM
combining mv and compress command sam_78_nyc Shell Programming and Scripting 4 11-06-2007 03:45 PM
Compress command indira UNIX for Dummies Questions & Answers 5 08-20-2007 02:04 PM
lp command with compress mode zita Linux 3 10-10-2005 05:25 AM
Help on compress command rahulrathod SCO 1 09-28-2004 04:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2002
tomapam tomapam is offline
Registered User
  
 

Join Date: Jul 2002
Posts: 17
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
  #2 (permalink)  
Old 10-11-2002
WIntellect's Avatar
WIntellect WIntellect is offline
Registered User
  
 

Join Date: Sep 2002
Location: United Kingdom
Posts: 170
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!
  #3 (permalink)  
Old 10-11-2002
Kelam_Magnus's Avatar
Kelam_Magnus Kelam_Magnus is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
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.

  #4 (permalink)  
Old 10-11-2002
witt
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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
echo "tar finished for " $name
done 2> error.log

If the version of your tar command donīt have the "-z" option, you can make a FIFO file (name pipe) with the mknod command.

Like this :

mknod backup_file_p p
gzip < backup_file_p > backup_file_p.gz &
tar -cvf backup_file_p /home/user_x
\rm backup_file_p


Witt
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0