cs-3424: add solution for Quiz 3
This commit is contained in:
parent
ca81dac9ba
commit
2e6f6d5a2e
@ -2,7 +2,7 @@
|
||||
|
||||
set -eEuo pipefail
|
||||
|
||||
SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||
LOG_FILE="${SCRIPT_DIR}/data/queries.log"
|
||||
DATA_DIR="${SCRIPT_DIR}/data"
|
||||
declare -A COURSE_DATA
|
||||
|
@ -53,8 +53,6 @@ read_course() {
|
||||
|
||||
_read_course "$dept_code" "$course_num" || return 1
|
||||
|
||||
printf "%s\n" "${COURSE_DATA[*]}"
|
||||
|
||||
cat <<-__EOS__
|
||||
Course department: ${COURSE_DATA["dept_code"]} ${COURSE_DATA["dept_name"]}
|
||||
Course number: ${COURSE_DATA["course_num"]}
|
||||
|
85
Summer-2024/CS-3424/Quizzes/Quiz-3/Assignment.typ
Normal file
85
Summer-2024/CS-3424/Quizzes/Quiz-3/Assignment.typ
Normal file
@ -0,0 +1,85 @@
|
||||
#set text(font: "FreeSans")
|
||||
#set page(margin: 1cm)
|
||||
|
||||
#show link: item => [
|
||||
#text(blue)[#item]
|
||||
]
|
||||
|
||||
#show raw: set text(font: "Fira Code")
|
||||
#show raw.where(block: true): item => {
|
||||
set par(leading: .5em)
|
||||
text(size: 0.9em)[#block(
|
||||
inset: 4pt,
|
||||
stroke: luma(40%) + .5pt,
|
||||
fill: luma(97%),
|
||||
radius: 3pt,
|
||||
)[#item]]
|
||||
}
|
||||
|
||||
|
||||
#let comment(com) = {
|
||||
text(size: 0.85em, style: "italic", fill: rgb(64, 90, 95))[#com]
|
||||
}
|
||||
|
||||
|
||||
#let answer(ans) = {
|
||||
align(center)[#block(
|
||||
inset: 4pt,
|
||||
stroke: blue + .5pt,
|
||||
fill: rgb(0, 149, 255, 5%),
|
||||
radius: 3pt,
|
||||
)[#ans]]
|
||||
}
|
||||
|
||||
#align(center)[#text(size: 1.3em)[= CS 3424 Quiz - Week 4]]
|
||||
#align(center)[
|
||||
#("Price Hiller", "zfp106", "Quiz 3", "CS 3424").join(" ⋄ ")
|
||||
#v(-.5em)
|
||||
#text(size: 0.75em)[#block(
|
||||
inset: 4pt,
|
||||
radius: 1pt,
|
||||
stroke: luma(40%) + .2pt,
|
||||
width: 40%,
|
||||
fill: luma(97%),
|
||||
)[#par(leading: .4em)[If you are interested in viewing the source code of this document, you can do so
|
||||
by clicking
|
||||
#link(
|
||||
"https://git.orion-technologies.io/Price/college/src/branch/Development/Summer-2024/CS-3424/Quizzes/Quiz-3/Assignment.typ",
|
||||
"here.",
|
||||
)]]]
|
||||
#v(-.5em)
|
||||
#line(length: 100%, stroke: (dash: "densely-dotted"))
|
||||
#v(-.5em)
|
||||
]
|
||||
|
||||
1. Use the appropriate utility to print all lines from files in the current
|
||||
directory _and subdirectories_ containing the string "main".
|
||||
#answer[
|
||||
#comment[
|
||||
Necessarily only works with files that the current user has access to.
|
||||
|
||||
Technically the `./` path is unnecessary as `grep` by default will do the
|
||||
recursive search from the current directory (as stored in `$PWD`), but
|
||||
being explicit is generally better as a rule of thumb.
|
||||
]
|
||||
```bash
|
||||
grep -r "main" ./
|
||||
```
|
||||
]
|
||||
2. Use the appropriate utility to list all directories and subdirectories (not
|
||||
files) belonging to the user [you are the user]
|
||||
#answer[
|
||||
#comment[
|
||||
I know for a fact that pretty much all Linux systems since the dawn of
|
||||
time will export the `$UID` variable for use, but the `$USER` variable may
|
||||
not be set depending on the system/kernel version. For _extreme_ backwards
|
||||
compatibility it's better to prefer `$UID` over `$USER` (but in a practical
|
||||
sense is more pedantic than "good practice", it doesn't matter that much).
|
||||
|
||||
I also redirect `STDERR` to `/dev/null` so we don't see any "Permission
|
||||
denied..." output.
|
||||
]
|
||||
```bash
|
||||
find ./ -type d -user "$UID" 2>/dev/null
|
||||
```
|
||||
]
|
Loading…
Reference in New Issue
Block a user