From 261bb9d58612ec7152f10209afb07f92f2adb6c3 Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Wed, 18 May 2022 21:14:20 +0200 Subject: [PATCH] ajout atelier functions --- Readme.md | 12 ++++++++++++ eval.sh | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 eval.sh diff --git a/Readme.md b/Readme.md index 681ff88..d48c5c2 100644 --- a/Readme.md +++ b/Readme.md @@ -1,5 +1,17 @@ ## Fonctions +### Exercice 1 + +Voir le fichier eval.sh + +Essayez d'identifier sa fonction + +Identifiez ses lacunes + +Proposez une correction + +### Exercice 2 + Définir dans le fichier myfunctions.sh une fonction "myerror" prenant 2 arguments en entrée: un code et un message. diff --git a/eval.sh b/eval.sh new file mode 100644 index 0000000..e236caf --- /dev/null +++ b/eval.sh @@ -0,0 +1,12 @@ +#! /bin/bash +IFS=$'\n\t' +host=$1 +root=${host}/rootfs +host=$(basename $host) +hostname=$(grep HOSTNAME ${root}/etc/sysconfig/network 2>/dev/null| cut -f2 -d=) +stat --printf "%y;" ${root}/root/.bash_history +stat --printf "%y;" ${root}/home/formation/.bash_history +stat --printf "%y;" ${root}/etc/motd +if( grep -i -qE "today" ${root}/etc/profile.d/zalias.sh ) ; then echo -ne "1;" ; else echo -ne "0;" fi +if( grep -i -qE "PS1" ${root}/etc/profile.d/zconf.sh ) ; then echo -ne "1;" ; else echo -ne "0;" fi +if( grep -i -qE "HISTSIZE" ${root}/etc/profile.d/zconf.sh ) ; then echo -ne "1;" ; else echo -ne "0;" fi