![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
|||||
|
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. ![]() |
|
||||
|
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 | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|