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

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

View Full Document Right Arrow Icon
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 TA’s 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
Image of page 1

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

View Full Document Right Arrow Icon
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 ------ ------ ---- ----- ---- ---- ------ ----
Image of page 2
5 Stored 5 0% 08-30-06 18:22 82ad0086 foo.sh 103 Defl:N 84 18% 09-10-06 14:45 f5e139a3 infile ------ ------ --- ------- 108 89 18% 2 To decompress the compressed archive, we have to use: {cs1:~} unzip archive.zip
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern