86 lines
2.5 KiB
Plaintext
86 lines
2.5 KiB
Plaintext
|
#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
|
||
|
```
|
||
|
]
|