Slides

Exercise 1

Open the terminal and perform the following tasks:

  1. What is your current working directory?
  2. In your current directory, make a directory named tmp
  3. Navigate into this new folder called tmp
  4. Add an empty file named tmp_file
  5. Within tmp, add an empty directory named another_tmp
  6. Within another_tmp, add an additional empty file named another_tmp_file

Execute the following code in your terminal:

# check your current working directory
pwd
# make a directory named tmp
mkdir tmp
# move into tmp 
cd tmp
# add an empty file named tmp_file
touch tmp_file
# add an empty directory named another_tmp
mkdir another_tmp
# add an empty file to another_tmp directory
touch another_tmp/another_tmp_file

Exercise 2

Form a group, figure out how to…

  1. list all files with sizes displayed in bytes/kilobyes/megabytes
  2. remove tmp_file
  3. rename another_tmp_file to such_a_cool_file
  4. remove tmp directory and all its contents

Execute the following code in your terminal. Note that this is one way and there are other possible solutions!

# list all files with sizes displayed in bytes/kilobyes/megabytes
ls -lhR
# remove `tmp_file`
rm tmp_file
# rename `another_tmp_file` to `such_a_cool_file`
cd another_tmp
mv another_tmp_file such_a_cool_file 
# remove `tmp` directory *and* all its contents
cd ../..
rm -r tmp

Exercise 3

In your breakout group, write bash code that executes each of the following.

  1. Write a sentence or two about Atlanta, or anything you’d like, and store it in a file called “atlanta.txt” within a folder called “atlanta”.
  2. Use vim to edit this file in some way (e.g. add some more text).
  3. Save the results and exit vim.
mkdir atlanta
echo "I work at Emory University and Live in Atlanta." > atlanta/atlanta.txt
vi atlanta/atlanta.txt

While in the vim environment:

i # insert allows you to edit text
YOUR TEXT INSERTED here
esc # gets out of text writing mode
:wq # saves your changes and exits vim

Additional readings