Outils pour utilisateurs

Outils du site


bash_cheat_sheet

Ceci est une ancienne révision du document !


Bash Cheat Sheet


Gestion des options

Les options doivent être avant les paramètres 'classique'

#!/bin/bash
  
#Gestion des options
optA=false;
optB=false;
cmd="ls";
  
while true
do
	case "$1" in
		-a)
			echo "option a"
			opta=true
			cmd+=" -a"
			shift
			;;
		-b)
			echo "option b"
			optb=true
			cmd+=" -b"
			shift;;
		*)
			break;;
	esac
done
  
if [[ $opta ]]
then
	echo "gagné A";
fi
if [[ optb ]]
then
	echo "gagné B"
fi;
 
echo "$cmd"
  
echo "$1";
bash_cheat_sheet.1748931087.txt.gz · Dernière modification : de pillow