-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.bash
More file actions
executable file
·37 lines (33 loc) · 947 Bytes
/
query.bash
File metadata and controls
executable file
·37 lines (33 loc) · 947 Bytes
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
#!/bin/bash
# Controllo che sia presente almeno un report
if [ $(ls | grep -c report) = "0" ];
then
echo "Nessun report presente"
else
file=$(ls -t report*.csv | head -1)
echo "Ultimo report: $file"
# Stampo a video quanti processi per ciascun utente ci sono nel report più recente
while read -r line
do
nomeFile=$(echo $line | cut -d " " -f2)
nprocessi=$(echo $line | cut -d " " -f1)
echo $nomeFile:$nprocessi
done <<< "$(cut -d ';' -f1 $file | sort -d | uniq -c)"
# Secondo punto
echo -e "\n"
read -p "Inserisci utente: " input
user=$(echo $input | cut -d ' ' -f1);
echo -e "\n"
# Controllo che non sia stato inserito un valore non valido
if [ -n "$user" ];
then
# Cerco quanti processi per l'utente ci sono in ciascun report
while read i
do
nprocessi=$(cut -d ';' -f1 $i | grep -wc $user)
echo report: $i processi $nprocessi
done <<< "$(ls report*.csv)"
else
echo "Utente inserito non valido"
fi
fi