Due: Tue. 01/27 at 11:59PM
Overview
In this exercise, you will practice navigating and modifying files in a complex directory structure. You will repeat exercises similar to this throughout the course of the semester. Over the course of the semester, the exercises will become slightly harder. The directory structure you work with is semi-randomly generated, so each student will receive a different ones each week to work with.
Receiving your exercise
You will generate a new directory structure to work with each time you
complete this exercise. There is a python script in the /home/ckazer/public
directory that you can execute to create a semi-random directory structure.
Navigate to where you would like to put the exercise files, and then run
$ python3 /home/ckazer/public/cs14/exercises/navigation/make_dir_structure_easy.py
Rather than copy-pasting this command, try typing it out using tab completion!
Follow the prompts to generate your exercise. This will create a directory
called treenav/.
Using asciinema
For this exercise, you must submit one or more asciinema recordings of you completing the exercise, as evidence of completing the assignment from the command line.
You can start an asciinema recording called naviagtion.cast as follows:
$ asciinema rec navigation.cast
Use Ctrl+d or enter the command exit to stop recording. If you record your
work in multiple sessions, give each recording a different name. E.g,
navigation_pt1.cast, navigation_pt2.cast, navigation_pt3.cast.
|
Warning
|
asciinema essentially functions as a "keystroke logger". You should
not enter any sensitive information, like passwords or other personal data,
while using it.
|
Completing the exercise
To begin with, there are three files you must find within treenav/:
-
re-name_me.txt -
remove_me.txt -
copy_me.txt
Each of the files contains instructions about what to do with the file. Use
cat to read their contents and perform the necessary operations.
Reminders
-
USE TAB COMPLETION!
-
press tab after writing a command and partially completing the name of a file or directory to auto-complete the name, assuming it is unique.
-
press tab multiple times to display the possible valid completions of a command, file, or directory if there is more than one option.
-
-
pwd-
If you don’t know where you are in the directory structure, use
pwdto "print the working directory" of where your terminal is currently.
-
-
ls-
lswith nothing after it will show the contents of the current working directory. -
lswith the name of a directory will show the contents of that directory, e.g. if your current directory contains another directory calledcs14/, thenls cs14/will show the contents ofcs14/.
-
-
cd-
cdwith nothing after it will return you to your home directory. -
You can use
cdto jump multiple directories at once, e.g.cd path/to/subdirectory. This works with tab completion! -
Use
cd ..to go back up a directory. This can be done multiple times at once, e.g.cd ../../../.
-
-
rm-
rm file_namewill attempt to deletefile_name -
Be careful! Files and directories removed with
rmgenerally cannot be recovered.
-
-
mv-
mvcan be used both to move files/directories and rename files/directories. -
mv a_file b_filechanges the name ofa_filetob_file -
mv a_file sub_dir/movesa_fileintosub_dir, keeping the namea_file. -
mv a_file sub_dir/b_filemovesa_fileintosub_dirAND changes its name tob_file.
-
-
cp-
cp a_file b_filecopies the contents ofa_fileintob_file. -
cpworks across directories. E.g.,cp a_file ../b_filewill create a copy ofa_filethat is one directory up calledb_file.
-
Submitting the exercise
For the first couple weeks, you will submit your completed exercises to a GitHub Enterprise repo. You can find your repo and clone it from the CS14 Org.
Clone you repository and either perform the exercise there, or put the modified
treenav directory and asciinema recording there once you are done.