Output, Download, and Uncompress

For Part 2 of This Lab…

We’re going to download a file and uncompress it. To do that, we’ll learn a few commands related to:

echo

Print to display →.

Think: an echo repeats what you say

echo say this again

clear

Clear screen →

(obvs). Bring prompt up to top so that it looks like you have a clear screen (you can still scroll up).

clear

control-c (interrupt a command)

Interrupt or stop a running command →

Think cancel. It’s the control key and the lowercase c key together.

[CONTROL] + [c]

curl

Download a file and display file. →

(Requires one argument, the URL of the page you’d like to display.)

curl http://someurl.com

Download a file and save it. →

curl -o filename.txt http://someurl.com

(the -o flag should be followed by the name of the file you want the URL to be saved as)

Don’t forget the -o flag! That’s the name of the file that the URL is downloaded as!

curl -o filename.txt http://someurl.com

unzip

Uncompress a zip file. Works on files with a .zip extension. →

unzip filename1.zip

(Requires one argument - the name of the file you want to uncompress)

tar (archive)

Archive directories and files. →

Think: T-archive, compress

tar -cvf archivename.tar directory_to_compress

(tar requires one argument, the directory to compress… and the -f flag requires the name of the resulting archive)

tar (extract)

Uncompress and unarchive a tarball. Works on files with a .tar.gz extension. →

Think: t-archive, xtract

tar -xvf archivename.tar.gz 

(exactly one argument, the name of the files to unarchive)

gzip

Compress a file. →

Think: zip

gzip filename.txt

(exactly one argument, the name of the files to compress)

tar and unzip are different!

tar vs unzip

Activity: Drills!

Entering commands flash cards x 5 (use set 2)

We’ll do this together, then try downloading it yourself:

  1. Download drills.py to the home directory
  2. Type python drills.py
  3. When prompted for a number, enter 2
  4. CTRL-C quits

Lab

Output, Download and Uncompress

Activity: Drills!

Entering commands flash cards x 3 (use set 12)

We’ll do this together, then try downloading it yourself:

  1. Download drills.py to the home directory
  2. Type python drills.py
  3. When prompted for a number, enter 12
  4. CTRL-C quits