Quick Links
Contact Us
Computer Science DepartmentSwarthmore College
500 College Avenue
Swarthmore, PA 19081
Phone: 610.328.8272
Fax: 610.328.8606
Email: info at cs.swarthmore.edu
Copyright 2009 Swarthmore College. All rights reserved.
using the tar command
tar is useful if you want to stuff a bunch of files and directories into one file. Then you can scp that file to another machine, untar it, and you have a nice copy of your original files and dirs.
Use the c option to create a tar file:
$ tar cvf cs21.tar cs21 cs21/ cs21/fortest.c cs21/ch02/ cs21/ch02/a.out cs21/ch02/coins.c cs21/ch02/comm/ cs21/ch02/comm/file1 cs21/ch02/comm/file2 cs21/ch02/ops.c cs21/ch03/ cs21/ch03/bug.c cs21/ch03/p14.c cs21/ch03/a.out cs21/ch03/p9.c cs21/ch03/randnum.c cs21/ch03/list cs21/ch03/p7.c cs21/project.html
This creates (c) a tar file (f) called cs21.tar, which contains everything in my cs21 dir. The original cs21 dir is still there and untouched.
Don't use the verbose (v) option if you don't want to see all of the filenames go by.
Use the x option to extract the contents of a tar file:
$ tar xvf cs21.tar cs21/ cs21/fortest.c cs21/ch02/ cs21/ch02/a.out cs21/ch02/coins.c cs21/ch02/comm/ cs21/ch02/comm/file1 cs21/ch02/comm/file2 cs21/ch02/ops.c cs21/ch03/ cs21/ch03/bug.c cs21/ch03/p14.c cs21/ch03/a.out cs21/ch03/p9.c cs21/ch03/randnum.c cs21/ch03/list cs21/ch03/p7.c cs21/project.html
This creates (or overwrites!) the cs21 directory and extracts all of the files and dirs from the tar file into the cs21 dir. The original cs21.tar file remains -- you can extract/untar as many times as you want.