Note: This can be a pair programming activity or done independently.
Developing web apps requires a degree of comfort navigating and interacting with your operating system through the command line. Later in the course, you'll be writing and running Python and JavaScript programs and running them from the command line. For now, we'll be practicing creating, modifying, and moving files and directories (in the Unix command line environment, we refer to folders as directories) in your terminal to get you practicing Unix commands.
So close Finder now and don't open it again. If you wanna use Finder to organize photos from your family holiday or sweet vacation last summer then that's fine, but never use it for anything related to web development! As developers we use the Unix command line almost exclusively for managing files and folde--whoops! I meant directories.
For your first lab, you're going to create files and directories to organize your favorite books, movies, and music. Then, you're going to reorganize them.
There are a couple links to Unix command cheatsheets in the "Additional Resources" section, and you could probably find dozens of useful ones on Google.
Nearly every Unix command has a what's called a "man page" (short for "manual page"). You can get extensive info about how any Unix command works by typing man and then the name of the program.
For example...
$ man ls...will give you exhaustive information about how the ls command works and the different options (called "flags") you can use to customize the output. It'll seem like too much information at first, because it is at this point, but get in the habit of using man pages now, and you'll learn to love them.
Hit the Q key to get out of the man page viewer.
-
In your directory for today, create a directory called
command-line-lab. Inside ofcommand-line-lab, create a directory calledmy-favorite-things. You'll use that directory to do the exercises below. -
Organize your favorite books
- in the
my-favorite-thingsdirectory, create a directory calledbooks - create a directory in books named after your favorite author (e.g.
mark_twain, orjohn-grisham, but avoid spaces!) - create files named after some of the author's books in the author's directory
- open the
booksdirectory in VS Code, Sublime, or Atom - edit each book file to contain a brief description of the book
- in the
-
Organize your favorite movies
- in the
my-favorite-thingsdirectory, create a directory calledmovies - create a directory in the movies directory named after your favorite actor
- create a directory in that actor directory named after that actor's breakthrough movie
- go back to the
moviesdirectory and create a text file named after the actor's character in their breakthrough movie - move the text file into the directory for that actor
- look back at your code editor and edit that text file to include a description of the character's role in the movie
- in the
-
Organize your favorite music
- in the
my-favorite-thingsdirectory, create a directory calledmusic - go into the
musicdirectory - create a directory called
disco - create a text file in
discocalledymca - delete the
discodirectory - create a directory called
creed - delete the
creeddirectory - create directories called
one-direction,the-strokes, andrihanna - create a text file in
one-directioncalledwhat-makes-you-beautiful.txt - from within
one-direction, copy (not move)what-makes-you-beautiful.txtintothe-strokesand also copy it intorihanna. rename those files with songs by those artists.
- in the
-
Reorganize everything
- in the
my-favorite-thingsdirectory, create a directory calledmedia - move
books,movies, andmusicinto themediadirectory
- in the
-
Organize the top music, movies, and books of 2015
- move to the
my-favorite-thingsdirectory and duplicate (make a copy of) themediadirectory—your copy should be named2015-media - in the
2015-mediadirectory, rename each directory to have2015-before the title - delete the contents of
2015-music,2015-movies, and2015-books - create a file called
top-ten-movies.htmlin2015-movies - create a file called
top-ten-songs.htmlin2015-music - create a file called
top-ten-books.htmlin2015-books - create an ordered list - using HTML! - of the top 10 movies, songs, and books in each of the appropriate files
- move to the
Bonus
-
Use man pages and google and the additional resources below to figure out how to do the following:
- find commands that let you look at the top/bottom 10 lines of each file
- figure out how search through a file from the command line - without opening the file - for a string of text
No starter code needed for this lab!
Be sure you open up your my-favorite-things directory in your code editor, so you can track your progress. Here's a look at what your files/directories should look like after each big step in the exercise:
- After "Organize your favorite books":
- After "Organize your favorite movies":
- After "Organize your favorite music":
- After "Reorganize everything"
- After "Organize the top music, movies, and books of 2015"
- MAN PAGES! (see "RTFM") The entire development community prizes self-reliance as a virtue. To succeed, developers need to persistent and driven solve problems on their own. Of course we'll guide you, keep an eye on you, and answer questions, but as we do so we will focus on instilling/enhancing this quality in our developers throughout the entire class.
- A list of CLI Shortcuts
- An awesome Unix command cheatsheet




