college/Summer-2024/CS-3424/Midterm-Notes.org

2.4 KiB

Systems Programming Midterm Topics

  1. Linux environment / shell commands

    • Common commands
    • Chmod/permissions
    • Wildcards
    • Input/output redirection
    • Shell parsing steps
    • Shell command resolution variables

      • Shell vs environment and their inheritance
    • Exit statuses
    • Subshells / child shells
    • Arithmetic (operators: expansion vs evaluation)

      • Floating arithmetic in bash: how?
  2. Bash Scripting
  3. find~/~grep
  4. Regular expressions (BRE vs ERE)
  5. sed

NOTE: No AWK material will be covered on the exam

Example Questions

  1. Answer True or False for the following statements:

    • [TRUE] The extended regular expression {0,1} is equivalent to the ? quantifier?
    • [FALSE] An exit status of 0 is used to indicate success.
    • [FALSE] Given the string "abc123" the regex /[a-z]{1,3}/ will produce a match of "a".
    • [FALSE] The following loop will never execute:

      while [ 0 ]; do let i++; echo $i; done
    • [TRUE] The following loop will never execute:

      while (( 0 )); do let i++; echo $i; done
    • [TRUE] sed will emit the contents of the pattern space, including a trailing newline character, by default at the end of each input cycle.
    • [FALSE] The following bash filename pattern will match all text files in the user's current directory:

      ls -la .*\.txt
    • [TRUE] The source built-in executes the contents of a specified file within the current script (i.e. no subshell is utilized).
    • [FALSE] grep uses extended regular expressions by default
  2. Enter the octal number corresponding to the following Linux file permissions: rwxr-x--- Answer: 0750
  3. Write out the erroneous line numbers from the following script (hint there are six):

    data="./data"
    org_data=/usr/local/courses/ssilvestro/cs3424/Spring21/assign1/
    
    if [[ $# -eq 1 ]]; then
        data = $1
    else if [[ $# -eq 2 ]]; then
        data = $1
        orig_data = $2
    fi
    
    if [[! -d $data]]; then
        echo "ERROR: data directory '$data' does not exist"
        exit 1
    fi
    if [[ not -d $orig_data ]]; then
        echo "ERROR: original data directory '$data' does not exist"
        exit 1
    fi
    echo "rm -rf \"$data\"..."
    rm -rf "$data"
    
    echo "cp -r \"$org_data\" \"$data\"..."
    cp -r "$orig_data" "$data"

    Answer: 4,5,6,7,9,13