Linux: Shell

  1. liste shells: cat /etc/shells
  2. indiquer l’analyseur: #!/bin/sh
  3. lancer fichier shell (/root/scripts/hello.sh)
    1. bash hello.sh
    2. sh hello.sh
    3. /root/scripts/hello.sh (#!/bin/bash)
    4. ./hello.sh
    5. source hello.sh (无子shell)
    6. . hello.sh(无子shell)
    7. si on met les fichier shell dans /bin/, on peut lancer directe, ou on peut ajouter le chemin du fichier dans le $PATH (echo $PATH)

Parametres:

  1. $HOME
  2. $PWD
  3. $SHELL
  4. $USER

Définir Variable:

  1. variable local: variable_a = abc
  2. variable global: export variable_a
  3. afficher variable: echo $variable_a
  4. quand on change dans le shell parent, le changement effectue dans tous les shell fils, si on change dans shell fils, le changement absent dans le shell parent
  5. supprimer une variable: unset variable_a

Variable dans le fichier shell:

  1. $n (chiffre, example: $1, $5, ${12})
  2. $0: Scripte Name
  3. $#: nombres de variables
  4. $* et $@, récupérer tout les variable, $* (str), $@(array)
  5. $?:

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

购物车