feat: Initial commit
This commit is contained in:
3
Lab07/es1.sh
Normal file
3
Lab07/es1.sh
Normal 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
9
Lab07/es2.sh
Normal 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
24
Lab07/es4.sh
Normal 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
22
Lab07/es5.sh
Normal 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
3
Lab07/input.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
the imagination of nature is far
|
||||
far greater than the imagination
|
||||
of man
|
||||
Reference in New Issue
Block a user