ajout du tp6

master
antoine.perederii 2 years ago
parent 6605b8643c
commit ae0d63d976

@ -0,0 +1,11 @@
#!/bin/sh
echo -n "$(basename $0) "
echo -n $1
shift
while [ "$1" != "" ]; do
echo -n "#$1"
shift
done
echo ""

@ -0,0 +1,16 @@
#!/bin/sh
if [ $# -eq 0 ] ; then
d="."
else
d="$1"
fi
for F in $(ls "$d") ; do
if [ -d "$d/$F" ] then
echo "[$F]"
elif [ -x "$d/$F" ] ; then
echo "$F*"
else
echo "$F"
fi
done

@ -0,0 +1,29 @@
#!/bin/sh
if ! test -d "$1"; then
echo 'Usage: dir dirname'
exit 1
fi
colors=$(tput colors)
dir_color=''
exe_color=''
ln_color=''
if test -n "$colors"; then
dir_color='\e[34m'
exe_color='\e[32m'
ln_color='\e[36m'
fi
for file in "$1"/*; do
if test -d "$file"; then
echo "$dir_color[$file]\e[0m"
elif test -x "$file"; then
echo "$exe_color*$file\e[0m"
elif test -h "$file"; then
echo "$ln_color*$file\e[0m"
else
echo "$file"
fi
done

@ -0,0 +1,17 @@
#!/bin/sh
echo "donnez une suite d'entiers (CTRL + d pour sortir) : "
read a #a contient le plus petit
if echo "$a" | egrep -q '^[0-9]+$' ; then
while read n ; do
if echo "$n" | egrep -q '^-?0-9+$' ; then
if [ $n -lt $a ] ; then
a=$n
fi
else echo "Attention !! il y a une erreur !!!" >&2
fi
done
else
echo "attention ! Votre arg doit etre un entiers" >&2
fi

@ -0,0 +1,12 @@
#!/bin/sh
pp=$1
for i ; do
if [ $i -lt $pp ] ; then
pp=$i
fi
done
if [ $i = 0 ]; then
echo "Erreur, le nombre est null !!!!" >&2
else
echo "Le plus petit est $i"
fi

@ -67,7 +67,7 @@ Exemple :
./arg1 toto titi tata
arg1 toto#titi#tata
```
``` echo "A K L OP PP M K K" | tr -s " " | tr -t " " "#"
## La commande `dir [répertoire]`

Loading…
Cancel
Save