+ Example / Exercise

Example 1

  1. Connect: ssh login.itd.umich.edu
  2. Print host: hostname
  3. Print working directory: pwd
  4. Create a directory: mkdir 506
  5. Move to that directory: cd 506
  6. Create a basic README.md to document your work in this folder:
    • echo "## Stats 506" > README.md
    • Append a blank line echo " " >> README.md
  7. Create additional directories:
    • mkdir ./hw; mkdir ./examples
    • mkdir ./data && mkdir ./data/csv
  8. Create multiple directories using a loop
for d in R Stata SAS sh
do
  mkdir ./examples/$d
  echo $d
done

Notes

Note the use of ; to execute multiple commands on the same line. It isn’t needed here, but && is used to execute the second command only if the first completes successfully. You can, but are not required to, read more about exit status and exit codes here.

Example 2

  1. Return to the home directory: cd $HOME, cd ~, or just cd
  2. Clone the 2019 student git repo, to give use some common files: git clone https://github.com/jbhender/Stats506_F19.git
  3. Move to the head of the repo: cd Stats506_F19
  4. See the folders with ls
  5. Check if tree is in $PATH using which and, if so, see the hierarchy with tree
  6. Find all Rmd files: find -iname "*.Rmd"
  7. Copy the Rmd template to your ‘~/506/R/’ directory, then move there with cd.
  8. Rename the Rmd template file using mv
  9. Delete the new file using rm
  10. Return to home
  11. Delete the entire Stats506_F19 repo using rm -rf ./Stats506_F19/.=