Voir .bashrc
98-petits-trucs-pour-configurer-l-historique-du-bash
CURDIR=$(dirname $(readlink -f $0))
Attention, bien mettre 2>&1 à la fin de la ligne
prog > log.txt 2>&1
file=$(printf 'FILE=_%s_%s.dat' $val1 $val2)
grep "test" test.txt if [ $? -gt 0 ]; then echo "ERROR!" fi
#!/bin/bash set -x ...
#!/bin/bash if [ $# -ne 2 ] then exit fi
#!/bin/bash while getopts lvxad:s:u:h opt do case $opt in d) DISPLAY="$OPTARG:0.0" DIS_CMD="-display $DISPLAY" export DISPLAY ;; s) SSH_CMD="ssh $OPTARG" HOSTNAME=$OPTARG ;; h) ACTION=HELP echo "help" ;; x) ACTION=XXREF ;; a) ACTION=XXREF_ALL ;; l) ACTION=LIST ;; u) USER=$OPTARG echo "user:" $USER ;; v) opt_verbose=1 ;; esac done shift $(($OPTIND - 1))
shopt -s extglob rm -rf -- !(.git)
#!/bin/bash F=”thisfile.txt” echo ${F#*.} txt echo ${F%.*} thisfile
if [ ! -f /tmp/foo.txt ] then echo the file does not exist fi
if [ ! -L /tmp/foo.txt ] then echo the link does not exist fi
#!/bin/bash echo -n "Suspend2" | dd of=/my_hibernation_image bs=1 conv=notrunc
#DIR prend la valeur du premier argument de la ligne de commande ou tmpdir DIR=${1:-$tmpdir}
if [ "$VAR" == "Test" ] then echo "var is Test" fi
if [ -z "$1" ] then echo "unset variable" else echo "variable is set" fi
#!/bin/bash A="abcd dcba" B=A C=${!B} echo $C
on utilise l'option -s de read
#!/bin/bash read -s password
#!/bin/bash $ A=2 $ B=3 $ C=$((A+B)) $ echo $C
#!/bin/bash if [[ $NUMBER =~ ^[0-9]+$ ]]; then echo ceci est un nombre else echo ceci n'est pas un nombre fi