summaryrefslogtreecommitdiff
path: root/os1w3/practicum.md
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-02-15 11:17:26 +0100
committerlonkaars <loek@pipeframe.xyz>2023-02-15 11:17:26 +0100
commitdb39bc7df6927dd81ccbe32dc5a247e619b58f86 (patch)
treea981701eabd9ce2606eb957f1df4f22a9b14012e /os1w3/practicum.md
parent3064926731fdbf3516e496fa1e905278defeccc3 (diff)
os week 3 klaar
Diffstat (limited to 'os1w3/practicum.md')
-rw-r--r--os1w3/practicum.md91
1 files changed, 91 insertions, 0 deletions
diff --git a/os1w3/practicum.md b/os1w3/practicum.md
new file mode 100644
index 0000000..ecc87ed
--- /dev/null
+++ b/os1w3/practicum.md
@@ -0,0 +1,91 @@
+# os week 3 practicum
+
+## 1
+
+```bash
+# print df met "human" sizes -> sorteer "human" op kolom 4 (delimiter automatisch)
+$ df -h | sort -hk4
+Filesystem Size Used Avail Use% Mounted on
+tmpfs 785M 64K 785M 1% /run/user/1000
+dev 3.9G 0 3.9G 0% /dev
+run 3.9G 1.2M 3.9G 1% /run
+tmpfs 3.9G 0 3.9G 0% /dev/shm
+tmpfs 3.9G 4.0K 3.9G 1% /tmp
+/dev/sda2 439G 228G 189G 55% /
+$
+```
+
+## 2
+
+```bash
+$ sort -u < opgave2.txt
+een
+en
+nog
+woord
+$ sort < opgave2.txt | uniq
+een
+en
+nog
+woord
+$
+```
+
+## 3
+
+Ik denk dat het commando `tee` zo heet omdat het een soort t-splitsing is maar
+dan voor i/o streams.
+
+```bash
+$ ls | tee listing.txt | wc -l
+6
+$ cat listing.txt
+huiswerk.md
+opgave2.txt
+os-hw.pdf
+os-p.pdf
+practicum.md
+windows.txt
+$
+```
+
+## 4
+
+```bash
+$ file windows.txt
+windows.txt: ASCII text, with CRLF line terminators
+$ xxd windows.txt
+00000000: 6861 6c6c 6f0d 0a68 616c 6c6f 0d0a 7769 hallo..hallo..wi
+00000010: 6e64 6f77 730d 0a ndows..
+$ tr -d '\r' < windows.txt > windows-utf8.txt
+$ file windows-utf8.txt
+windows-utf8.txt: ASCII text
+$ xxd windows-utf8.txt
+00000000: 6861 6c6c 6f0a 6861 6c6c 6f0a 7769 6e64 hallo.hallo.wind
+00000010: 6f77 730a ows.
+$
+```
+
+## 5
+
+```bash
+# a (zie dat 0x0d 0x0a verandert naar 0x0a)
+$ hexdump -C < windows.txt | head -n2
+00000000 68 61 6c 6c 6f 0d 0a 68 61 6c 6c 6f 0d 0a 77 69 |hallo..hallo..wi|
+00000010 6e 64 6f 77 73 0d 0a |ndows..|
+$ hexdump -C < windows-utf8.txt | head -n2
+00000000 68 61 6c 6c 6f 0a 68 61 6c 6c 6f 0a 77 69 6e 64 |hallo.hallo.wind|
+00000010 6f 77 73 0a |ows.|
+$
+# b
+$ wc -c < windows.txt
+23
+# 23 bytes in windows.txt
+$ wc -c < windows-utf8.txt
+20
+# 20 - 3 bytes in windows-utf8.txt
+$ wc -l < windows.txt
+3
+# 3 regels in windows.txt (per regel een \r\n)
+$
+```