Expension

De Linuxmemo.

(Différences entre les versions)
(Bash expension)
 
(3 versions intermédiaires masquées)
Ligne 1 : Ligne 1 :
[[Catégorie:Bash]]
[[Catégorie:Bash]]
 +
ref: http://wiki.bash-hackers.org/syntax/pe
 +
 +
Ne pas confondre avec les expensions de variable: http://linuxmemo.free.fr/index.php?title=Varibles_bash#Expension_de_variable
 +
==Bash expension==
==Bash expension==
-
  mkdir rep{1,2,3}
+
  mkdir rep'''{1,2,3}'''
  mkdir: création du répertoire «rep1»
  mkdir: création du répertoire «rep1»
  mkdir: création du répertoire «rep2»
  mkdir: création du répertoire «rep2»
Ligne 8 : Ligne 12 :
-
  cp ntp.conf{,.bak}
+
  cp ntp.conf'''{,.bak}'''
  «ntp.conf» -> «ntp.conf.bak»
  «ntp.conf» -> «ntp.conf.bak»
  ls ntp*
  ls ntp*
Ligne 19 : Ligne 23 :
  ntp.conf.bak
  ntp.conf.bak
-
+
==Bash brace expension==
-
 
+
http://wiki.bash-hackers.org/syntax/expansion/brace
-
  for i in {1..12};do ping -c 1 192.168.0.{$i} ;done
+
  for i in '''{1..12}''';do ping -c 1 192.168.0.{$i} ;done

Version actuelle en date du 12 septembre 2019 à 12:30

ref: http://wiki.bash-hackers.org/syntax/pe

Ne pas confondre avec les expensions de variable: http://linuxmemo.free.fr/index.php?title=Varibles_bash#Expension_de_variable

[modifier] Bash expension

mkdir rep{1,2,3}
mkdir: création du répertoire «rep1»
mkdir: création du répertoire «rep2»
mkdir: création du répertoire «rep3»


cp ntp.conf{,.bak}
«ntp.conf» -> «ntp.conf.bak»
ls ntp*
ntp.conf  ntp.conf.bak


mv ntp.conf{,.bak}
«ntp.conf» -> «ntp.conf.bak»
ls ntp*
ntp.conf.bak

[modifier] Bash brace expension

http://wiki.bash-hackers.org/syntax/expansion/brace

for i in {1..12};do ping -c 1 192.168.0.{$i} ;done
Outils personnels