Tutorial 7 - Tutorial 7 In this tutorial, you will learn...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Tutorial 7 In this tutorial, you will learn some advanced file operations in UNIX. In the beginning of this tutorial, the file compression and de-compression commands in UNIX are presented. Then you will learn some operations on file alias and searching. The commands for using ftp in UNIX are illustrated in the end of this tutorial. There are examples in every section of this tutorial. The examples have been done using the TAs directories that you may not be able to access. But if you like you can redo the examples by changing the directories to those you own. The Archival Program For sending a group of files to someone either by FTP or email, it helps to combine them into a single filed called an archive. The tar (tape archiver) command which does the thing. Only one option can be used at a time:-c Creates an archive-x Extracts files from archive-t Displays files in archive In addition, we will frequently use two options: -f for specifying the name of the archive and -v to display the progress. Here, we create a file archive, archive.tar, from two uncompressed files: {cs1:~} tar -cvf archive.tar foo.sh foo.bak a foo.sh 1K a foo.bak 1K To extract the archive: {cs1:~} tar -xvf archive.tar tar: blocksize = 6 x foo.sh, 5 bytes, 1 tape blocks x foo.bak, 5 bytes, 1 tape blocks To view the archive: {cs1:~} tar -tvf archive.tar tar: blocksize = 6-rwx--x--x 92977/215 5 Aug 30 18:22 2006 foo.sh-r-x--x--x 92977/215 5 Sep 10 12:32 2006 foo.bak The Compression Program gzip compresses a file and gunzip decompresses it. For example: {cs1:~} gzip infile This creates a gzipped file named "infile.gz". To view the amount of compression we can use -l option: {cs1:~} gzip -l infile.gz compressed uncompr. ratio uncompressed_name 109 103 18.4% infile To uncompress a gzipped file we can use either of the two 'gzip -d' or gunzip commands. For example, {cs1:~} gzip -d infile.gz Or {cs1:~} gunzip infile.gz An additional layer of compression helps bring down the file size, the reason why gzip is ofter used with tar for creating a compressed archive. Here we gzip the file archive.tar that was created before with tar: {cs1:~} gzip archive.tar This creates a "tar-gzipped" file, archive.tar.gz. To extract the file we can use: {cs1:~} gunzip archive.tar.gz The Compression and Archival Program The 'zip; command combines the compressing function of gzip with the archival function of tar. zip requires the first argument to be the compressed filename, the remaining arguments are interpreted as files and directories to be compressed. For example, {cs1:~} zip archive.zip foo.sh infile adding: foo.sh (stored 0%) adding: infile (deflated 18%) To view the content of the archive, we can use the command 'unzip' with the option -v: {cs1:~} unzip -v archive.zip Archive: archive.zip Length Method Size Ratio Date Time CRC-32 Name------ ------ ---- ----- ---- ---- ------ ---- 5 Stored 5 0% 08-30-06 18:22 82ad0086 foo.sh 103 Defl:N 84 18% 09-10-06 14:45 f5e139a3 infile------ ------ --- -------...
View Full Document

This note was uploaded on 12/12/2009 for the course CS 3375 taught by Professor Kendracooper during the Fall '08 term at University of Texas at Dallas, Richardson.

Page1 / 9

Tutorial 7 - Tutorial 7 In this tutorial, you will learn...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online