Unit 7 Practice: Command Line Solution
- Change directories into the
learn-code-unit-7repo you downloaded/cloned. From now on, we will refer to this as the root directory, or simply root.$ cd path/to/repo/learn-code-unit-7 - Remove the Readme file.
$ rm README.md - Create a file called
hello.txt.$ touch hello.txt - Add the following line to
hello.txt(without quotes): “world”$ echo "world" > hello.txt - Print the contents of
hello.txt.$ cat hello.txt world - Change directories into
src/com/omegarobotics.$ cd src/com/omegarobotics # alternative solution $ cd src $ cd com $ cd omegarobotics - List all of the files in this directory.
$ ls books.txt opmode.txt songs.txt tvshows.txt - Go back up one directory.
$ cd .. - Print the directory you’re in.
$ pwd /Users/yourname/path/to/repo/learn-code-unit-7/src/com - Create a new directory called
practice.$ mkdir practice - Change into the
practicedirectory.$ cd practice - Create a file called
name.txt.$ touch name.txt - Add the following line to
name.txt(without quotes): “Jane Doe”$ echo "Jane Doe" > name.txt - Go back up one directory.
$ cd .. - Print the directory you’re in.
$ pwd /Users/yourname/path/to/repo/learn-code-unit-7/src - Remove the
comdirectory.$ rm -r com
Note: You should not use rmdir because it won’t work. Remember that rmdir is only to remove empty directories, while rm -r is for nonempty directories.