User Tools

Site Tools


bash

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
bash [2010/04/26 15:20] ginkobash [2014/05/27 11:02] (current) – [Cheat Sheet] ginko
Line 1: Line 1:
 Bash est un langage de shell de linux. Bash est un langage de shell de linux.
 Il est installé par défaut sur Ubuntu. Il est installé par défaut sur Ubuntu.
 +====== UI ======
 +  * [[http://eriwen.com/bash/effective-shorthand/|Utiliser efficacement bash]]
 ====== Cheat Sheet ====== ====== Cheat Sheet ======
 +  * [[bash_cheatsheet|Bash parameters & history cheatsheet]]
 ===== Shebang ===== ===== Shebang =====
 <code bash>#!/bin/bash</code> <code bash>#!/bin/bash</code>
Line 35: Line 38:
   * [[http://fr.wikibooks.org/wiki/Programmation_Bash/Tests]]   * [[http://fr.wikibooks.org/wiki/Programmation_Bash/Tests]]
   * [[http://abs.traduc.org/abs-5.0-fr/ch07.html]]   * [[http://abs.traduc.org/abs-5.0-fr/ch07.html]]
 +  * [[http://tldp.org/LDP/abs/html/comparison-ops.html|Opérateurs de comparaison]]
  
 ===== Variables ===== ===== Variables =====
Line 52: Line 56:
 >5 >5
 echo 'il y a $x pommes dans mon sac' echo 'il y a $x pommes dans mon sac'
->''il y a 5 pommes dans mon sac'</code>+>'il y a 5 pommes dans mon sac'</code>
 Le sigil est notamment utilisé en bash, PHP et Perl. Le sigil est notamment utilisé en bash, PHP et Perl.
  
Line 66: Line 70:
  
 ====== Astuces ====== ====== Astuces ======
 +
 +===== Everyday shell life =====
 +Pour se simplifier la vie :
 +  * les [[shell:alias|alias]]
 +  * les [[shell:export|exports]]
 +  * l'[[shell:inputrc|inputrc]]
 +  * l'[[shell:history|historique]]
 ===== notify-send ===== ===== notify-send =====
 La commande notify-send est intallée dans le paquet libnotify dans les dépôts debian. La commande notify-send est intallée dans le paquet libnotify dans les dépôts debian.
Line 78: Line 89:
  
 ===== Options & getopts ===== ===== Options & getopts =====
 +Un petit script d'exemple :
 +<code bash>#! /usr/bin/bash
 +# -*- coding: utf-8 -*-
 +
 +echo $@
 +while getopts "ab:c" opt; do # a letter followed by a colon means an option expecting an operand
 +                             # a colon at the beginning means "no warning message"
 +    case $opt in
 +        a) a=1;;
 +        b) b=$OPTARG;; # OPTARG is set to the corresponding operand
 +        c) c=1;;
 +        *) echo plop;;
 +    esac
 +done
 +shift $(($OPTIND-1)) # OPTIND is set to the first argument not processed by getopts => command shifts to the first non optionnal arg
 +echo "a: $a; b: $b; c: $c"
 +echo $@
 +</code>
   * [[http://www.ibm.com/developerworks/library/l-bash-parameters.html?ca=drs-]]   * [[http://www.ibm.com/developerworks/library/l-bash-parameters.html?ca=drs-]]
   * [[http://unix.sjcc.edu/cis157/BashParameters.htm]]   * [[http://unix.sjcc.edu/cis157/BashParameters.htm]]
Line 94: Line 123:
   * [[ip_forwarding]]   * [[ip_forwarding]]
   * [[rhythmbox-load]]   * [[rhythmbox-load]]
 +===== Commandes Unix =====
 +  * <code bash>#Backup a USB Key
 +# To list partitions: fdisk -l (with root privilegies)
 +dd if=/dev/sdc1 of=/home/user/usb4go_bak.iso bs=16065b</code>
 +===== Useful =====
 +  * Convertir les html entities dans les noms de fichier (ex. : ''%20'' en ''_'') : <code bash>for f in $(ls -1); do mv $f ${f//%20/_} ; done</code>
 +
  
  
bash.1272288037.txt.gz · Last modified: 2010/04/26 15:20 by ginko