Zipping


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Zipping
# 1  
Old 03-02-2018
Zipping

Good Morning,

I'd like to archive an old user's files in the home directory on Solaris 9

Will this work?



Code:
cd home
tar -zcvf jsmitharchive.tar.gz jsmith/

---------- Post updated at 09:37 AM ---------- Previous update was at 09:33 AM ----------

Also- is the last
Code:
/

necessary (after jsmith)
# 2  
Old 03-02-2018
Code:
cd home
tar -zcvf jsmitharchive.tar.gz ./jsmith

i.e. archive the directory 'jsmith' which is below the directory I'm in now '.'
# 3  
Old 03-02-2018
OK Thanks!

That's interesting. I've only seen that used when running an application or script while I'm in the directory- not when something is a "target" of a command. Could I also do
Code:
tar -zcvf jsmitharchive.tar.gz /home/jsmith

without
Code:
cd home

?
# 4  
Old 03-02-2018
Yes, you could but look up the difference between relative and absolute pathing.

If you use /home/jsmith then you can (normally) only restore it to that location, whereas, if you archive it with a relative name '.' you can restore it anywhere.

So when your user reports that he has lost a file you can restore the archive in some completely different location WITHOUT overwriting his current files. That's why most pro's always use relative pathnames.
# 5  
Old 03-05-2018
Quote:
Originally Posted by Stellaman1977
Good Morning,

I'd like to archive an old user's files in the home directory on Solaris 9

Will this work?

Code:
cd home
tar -zcvf jsmitharchive.tar.gz jsmith/

Solaris tar does not support the GNU option z to send it through gzip. Instead use
Code:
cd home
tar cvf - jsmith | gzip -c > jsmitharchive.tar.gz

Remember also that tar extracts files to the path they were archived from, so if you use
Code:
tar cvf archive.tar /home/jsmith

and then extract the archive it will overwrite a new /home/jsmith (GNU versions of tar strip the leading '/' to stop this from happening).

Quote:
Also- is the last
Code:
/

necessary (after jsmith)
No.

Andrew
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with grouping and zipping

Hi can you please help with the below ? source file: Column1,Column2,Column3,Column4 abc,123,dir1/FXX/F19,1 abc,123,dir1/FXX/F20,1 abc,123,dir1/FXX/F23,2 abc,123,dir1/FXX/C25,2 abc,123,dir1/FXX/X25,2 abc,123,dir1/FXX/A23,3 abc,123,dir1/FXX/Z25,3 abc,123,dir1/FXX/Y25,4 I want to... (3 Replies)
Discussion started by: paul1234
3 Replies

2. Shell Programming and Scripting

Zipping files

Hi Guys, The script below works but it creates a zip folder under 123_arch.zip -- test1 -- orig1.txt -- orig2.txt -- orig3.txt -- orig4.txt I don't want the sub directory test1 but everything under the base *arch name I can not create a long name with... (4 Replies)
Discussion started by: GaryP1973
4 Replies

3. UNIX for Dummies Questions & Answers

Zipping files

Hi All, I have a scenario where in am using uuencode to send a txt file as an excel to end users( email attachment).I have 7 different files and these files are sent as emails 7 times... So my question is, can i not zip all the 7 files at once and attach those files in a single... (9 Replies)
Discussion started by: saggiboy10
9 Replies

4. UNIX for Dummies Questions & Answers

Help With zipping a file

Hi I need to zip a file and move it into another folder along with the timestamp. The orginal file must be removed from the source directory Source : folder1/source12.txt folder2 After zipping Folder1/Folder2/source12.zip Any help will be greatly appreciarted ... (5 Replies)
Discussion started by: akshay01987
5 Replies

5. Shell Programming and Scripting

zipping files

Hi, Is there any difference if files are individually zipped and archived in a directory or if files are moved into archiving directory and zipping that directory. (3 Replies)
Discussion started by: swathich
3 Replies

6. UNIX for Dummies Questions & Answers

Zipping files?

how would i zip a file? what does zip mean? (4 Replies)
Discussion started by: trob
4 Replies

7. Shell Programming and Scripting

zipping files

Dear Experts, I need a script which will zipped the files older than 2 days. but i dont want to use find . * -mtime 2. Is there is any other method to achive this task. i will ececute the script daily. Regards, (3 Replies)
Discussion started by: shary
3 Replies

8. UNIX for Advanced & Expert Users

Help me While zipping the file

Hi , I have written code which will ask the subject,body of the mail, attachment and mail id of the receipient. Code will pick up 4 files zip it. It will zip all the files and then post the mail to the receipient. While zipping the file i am getting error. Can anyone help me with this. ... (7 Replies)
Discussion started by: Jolly
7 Replies

9. UNIX for Dummies Questions & Answers

Zipping

Hi In unix i want to zip the files in a directory excluding *.dmp, *.log, *.lst, *.out files in that directory. pls let me know what command to use. $zip ........ ? Thanks (1 Reply)
Discussion started by: dreams5617
1 Replies

10. Shell Programming and Scripting

zipping in a loop

Hello All, I have a requirement that i need to gzip each file that is more than 5 days old inside a directory. Could some one help me with the script ? do i need to write a for loop or can be done through single command? Thanks, Sateesh (2 Replies)
Discussion started by: kotasateesh
2 Replies
Login or Register to Ask a Question