tp2-adminsys/2_while.sh

23 lines
425 B
Bash
Raw Normal View History

2022-10-12 07:54:19 +00:00
#!/bin/bash
2022-10-12 09:21:33 +00:00
fichier="/etc/services"
2022-10-12 07:54:19 +00:00
2022-10-12 09:21:33 +00:00
while read ligne
do
if [ ! -z "$ligne" ] && [[ ! "$ligne" =~ ^#.* ]]
then
# Pour afficher la ligne seule
# echo $ligne
port=$(echo "$ligne" | cut -f3)
soft=$(echo "$ligne" | cut -f1)
if [ ! -z "$port" ]
then
#Pour afficher le port seul
#echo "Port $port"
#Affichage port + nom du logiciel
echo "Port / nom prog. : $port $soft"
fi
fi
done < $fichier