-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReeks9
45 lines (35 loc) · 944 Bytes
/
Reeks9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#oef 1.a
set hoi.txt
[[ -f $1 ]] && {
aantalregels=$(wc -l < $1)
totwoorden=$(wc -w < $1)
totchars=$(wc -m < $1)
echo "aantalregels: " $aantalregels
echo "aantal woorden: " $totwoorden
echo "aantal chars: " $totchars
echo "gem woorden: " $(($totwoorden / $aantalregels))
echo "gem chars: " $(($totchars / $aantalregels))
}
#oef 1.b
set hoi.txt
[[ -f $1 ]] && {
aantalregels=$(wc -l $1 | cut -d\ -f1 )
totwoorden=$(wc -w $1 | cut -d\ -f1 )
totchars=$(wc -m < $1 | cut -d\ -f1 )
echo "aantalregels: " $aantalregels
echo "aantal woorden: " $totwoorden
echo "aantal chars: " $totchars
echo "gem woorden: " $(($totwoorden / $aantalregels))
echo "gem chars: " $(($totchars / $aantalregels))
}
#oef 3
user="root"
cat /etc/passwd | grep -E ^$user | cut -d: -f1
cat /etc/passwd | grep -E ^$user | cut -d: -f3
#oef 4
set hoi.txt 5
(( $# == 1 )) && { aantal=11; } || { aantal=$(($2+1)); }
[[ -f $1 ]] && {
cat $1 | tail -n $aantal
}
#oef 5