Herramientas de usuario

Herramientas del sitio


ejemplos:scripting

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
ejemplos:scripting [2008/02/16 15:42]
fmolinuevo
ejemplos:scripting [2015/02/26 11:49] (actual)
fmolinuevo [Script 4]
Línea 1: Línea 1:
 ====== Scripting: ejemplos básicos ====== ====== Scripting: ejemplos básicos ======
  
 +//Nota//: The magical incantation '​2>&​1'​ has more meaning when it is considered that, when running in a UNIX or UNIX-like environment,​ each file opened (for reading or writing) is assigned a file descriptor number. By default, all commands have three file descriptors open as they run: STDIN (standard input), STDOUT (standard output), and STDERR (standard error). These are assigned the numbers 0, 1, and 2 respectively. So in the given syntax, '​2'​ means standard error, '>'​ means '​2'​ is being redirected, '&'​ means '​1'​ is a file descriptor (and not a file named '​1'​),​ and '​1'​ means standard output. The reason '​2>&​1'​ is specified after STDOUT is redirected to a file is that the command is read by the shell interpreter from left to right and descriptors are resolved immediately. If '​2>&​1'​ came first, STDERR would go to the original STDOUT (and not the file), which is not what I want here. 
 ===== Script 1 ===== ===== Script 1 =====
  
Línea 45: Línea 46:
 for i in joselo jose sergio alberto melisa felix for i in joselo jose sergio alberto melisa felix
 do do
-    if [ $i == '​felix'​ ]+    if [ $i = '​felix'​ ]
     then     then
  echo "$i es profe"  echo "$i es profe"
ejemplos/scripting.1203183720.txt.gz · Última modificación: 2012/01/27 17:46 (editor externo)