1
0

feat: Initial commit

This commit is contained in:
2024-03-22 16:54:05 +01:00
parent 0d9957a125
commit d993185b89
25 changed files with 641 additions and 0 deletions

3
Lab07/es1.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash -v
grep -rHn "$2" $1 | sort -t ":" -k 1,1 -k 2,2rn > $3

9
Lab07/es2.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
for line in $(cat $1)
do
echo $line | wc -m
done | sort -r -n | head -n 1
wc -l $1

24
Lab07/es4.sh Normal file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
declare -A acr
if [ $# -ne 1 ]
then
echo "Missing filename"
exit 1
fi
for word in `cat $1`
do
if [ -v "acr[$word]" ]
then
acr[$word]=$((acr[$word]+1))
else
acr[$word]=1
fi
done
for key in ${!acr[*]}
do
echo "${key}: ${acr[$key]}"
done

22
Lab07/es5.sh Normal file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
finds=0
while :
do
line=$(ps -el | tr -s " " | cut -d " " -f 2,4,14 | grep $1 | cut -d " " -f 1,2)
if [[ $(echo $line | cut -d " " -f 1) = "Z" ]]
then
let finds++
if [[ $finds -ge 5 ]]; then
pid=$(echo $line | cut -d " " -f 2)
kill -9 $pid
echo "Killed process $pid"
exit 0
fi
elif [[ $finds -ne 0 ]]
then
finds=0
fi
sleep $2
done

3
Lab07/input.txt Normal file
View File

@@ -0,0 +1,3 @@
the imagination of nature is far
far greater than the imagination
of man