File tree 15 files changed +226
-0
lines changed
15 files changed +226
-0
lines changed Original file line number Diff line number Diff line change
1
+ # !/bin/bash
2
+ # Programa para ejemplificar el uso de descarga de informacion desde internet utilizando el comando wget
3
+
4
+ echo " Descarga informacion de internet"
5
+ wget wget https://www-us.apache.org/dist/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.zip
6
+
7
+
Original file line number Diff line number Diff line change
1
+ # !/bin/bash
2
+ # Programa para ejemplificar el uso de la sentencia de desicion if, else
3
+ # Author: Luis Antonio preza - @anibulus
4
+
5
+ notaDeClase=0
6
+ edad=0
7
+
8
+ echo " Ejemplo sentencia If - else"
9
+ read -n1 -p " Indique cual es su nota (1-9)" notaDeClase
10
+ echo -e " \n"
11
+ if (( $notaDeClase >= 7 )) ; then
12
+ echo " El alumno aprueba la materia"
13
+ else
14
+ echo " El alumno reprueba la materia"
15
+ fi
16
+
17
+ read -p " Indique cual es su edad" edad
18
+ if [ $edad -le 18 ]; then # Lowe equals
19
+ echo " La persona es menor de edad"
20
+ else
21
+ echo " La persona es mayor de edad"
22
+ fi
23
+
24
+
25
+
Original file line number Diff line number Diff line change
1
+ # !/bin/bash
2
+ # Programa para ejemplificar el uso de la sentencia de desicion if else if else
3
+ # Author: Luis Antonio preza - @anibulus
4
+
5
+ edad=0
6
+
7
+ read -p " Indique cual es su edad" edad
8
+ if [ $edad -le 18 ]; then # Lowe equals
9
+ echo " La persona es ADOLECENTE"
10
+ elif [ $edad -ge 19 ] && [ $edad -le 64 ]; then
11
+ echo " La persona es ADULTA"
12
+ else
13
+ echo " La persona es ADULTO MAYOR"
14
+ fi
15
+
16
+
17
+
Original file line number Diff line number Diff line change
1
+ # Da una conotacion para que se procese como shel y haya soporte para programar
2
+ # !/bin/bash
3
+ # Programa para realizar opetaciones utilitarias de postgres
4
+
5
+ echo " Hola, bienvenido al curso de programacion bash"
6
+
7
+
Original file line number Diff line number Diff line change
1
+ # !/bin/bash
2
+ # Programa para revisar la declaracion de variables
3
+
4
+ opcion=0
5
+ nombre=Luis
6
+
7
+ echo:" Opcion: $opcion y Nombre: $nombre "
8
+
9
+ # Exportar la variable nombre para que este disponibe a los demas procesos
10
+ export nombre
11
+
12
+ # Llamar al siguiente script para recuperar la variable
13
+ bash 2_variables_2.sh
Original file line number Diff line number Diff line change
1
+ # !/bin/bash
2
+ # esc DD para borrar una linea completa
3
+
4
+ echo" Opcion nombre del script anterior: $nombre "
5
+
Original file line number Diff line number Diff line change
1
+ # !/bin/bash
2
+ # Programa para revisar los tipos de operadores
3
+ # Author: Luis Antonio Preza - anibulusnn@gmail.com
4
+
5
+ echo " Operadores aritmeticos"
6
+ echo " Dame un numero"
7
+ read num1
8
+ echo " Dame otro numero"
9
+ read num2
10
+
11
+ echo " Operadores aritmeticos"
12
+ echo " Sumar $num1 + $num2 = $(( num1 + num2 )) "
13
+ echo " Restar $num1 - $num2 = $(( num1 - num2 )) "
14
+ echo " Multiplicar $num1 * $num2 = $(( num1 * num2 )) "
15
+ echo " Dividir $num1 / $num2 = $(( num1 / num2 )) "
16
+ echo " Residuo $num1 % $num2 = $(( num1 % num2 )) "
17
+
18
+
19
+ echo -e " \n Operadores relacionales"
20
+ echo " $num1 < $num2 = $(( num1 < num2 )) "
21
+ echo " $num1 > $num2 = $(( num1 > num2 )) "
22
+ echo " $num1 <= $num2 = $(( num1 <= num2 )) "
23
+ echo " $num1 >= $num2 = $(( num1 >= num2 )) "
24
+ echo " $num1 == $num2 = $(( num1 == num2 )) "
25
+ echo " $num1 != $num2 = $(( num1 != num2 )) "
26
+
27
+
28
+ echo -e " \n Operadores asignacion"
29
+ echo " Sumar $num1 += $num2 = $(( num1 += num2 )) "
30
+ echo " Restar $num1 -= $num2 = $(( num1 -= num2 )) "
31
+ echo " Sumar $num1 *= $num2 = $(( num1 *= num2 )) "
32
+ echo " Sumar $num1 /= $num2 = $(( num1 /= num2 )) "
33
+ echo " Sumar $num1 %= $num2 = $(( num1 %= num2 )) "
34
+
35
+
36
+
37
+
Original file line number Diff line number Diff line change
1
+ # ! /bin/bash
2
+ # Programa para ejemplificar el paso de argumentos
3
+
4
+ nombreCurso=$1
5
+ horarioCurso=$2
6
+
7
+ echo " El nombre del curso es $nombreCurso dictado en el horario de $horarioCurso "
8
+ echo " El numero de parametros enviados es $# "
9
+ echo " Los parametros enviados son $* "
10
+
11
+
Original file line number Diff line number Diff line change
1
+ # !/bin/bash
2
+ # Programa para revisar como ejecutar comandos dentro de un programa y almacenar en una variable para utilizar en los tipos de operadores
3
+ # Author: Luis Antonio Preza - anibulusnn@gmail.com
4
+
5
+
6
+ ubicacionActual=` pwd`
7
+ infoKernel=$( uname -a)
8
+
9
+ echo " La ubicacion actual es la siguiente: $ubicacionActual "
10
+ echo " Informacion del kernel: $infoKernel "
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Programa para ejemplificar como capturar la informacion del usuario utilizando el comando echo, read y $Reply
3
+
4
+ option=0
5
+ backupName=" "
6
+
7
+ echo " Programa de utilidades postgres"
8
+ echo -n " Ingresar una opcion:"
9
+ read
10
+ option=$REPLY
11
+ echo -n " Ingresar el nombre del backup"
12
+ read
13
+ backupName=$REPLY
14
+ echo " Opcion $option , backupName $backupName "
15
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Programa para ejemplificar como capturar la informacion del usuario utilizando el comando read
3
+
4
+ option=0
5
+ backupName=" "
6
+
7
+ echo " Programa de utilidades postgres"
8
+ read -p " Ingresar una opcion:" option
9
+ read -p " Ingresar el nombre del backup" backupName
10
+ echo " Opcion $option , backupName $backupName "
11
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Programa que valida el input
3
+
4
+ read -n1 -p " Ingresa un numero" numero
5
+ echo $numero
6
+
7
+ read -s -p " Ingresa un numero" clave
8
+ echo " Clave: $clave "
9
+
10
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Como se realiza el paso de opcioens con o sin parametros
3
+
4
+
5
+ echo " Opciones"
6
+ echo " Opcion 1 enviada: $1 "
7
+ echo " Opcion 2 enviada: $2 "
8
+ echo " Opcion enviadas: $* "
9
+ echo -e " \n"
10
+ echo " Recuperar valores"
11
+ while [ -n " $1 " ]
12
+ do
13
+ case " $1 " in
14
+ -a) echo " -a option utilizada" ;;
15
+ -b) echo " -b option utilizada" ;;
16
+ -c) echo " -c option utilizada" ;;
17
+ * ) echo " $1 no es una opcion" ;;
18
+ esac
19
+ shift
20
+ done
21
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Programa para validaciones regex
3
+ # Author: Luis Antonio Preza
4
+
5
+ regexNumber=' ^[0-9]{10}$' # 10 numeros
6
+ regexPais=' ^EC|COL|US|MEX$'
7
+ regexNacimiento=' ^19|20[0-8]{2}[1-12][1-31]$'
8
+
9
+ read -p " Ingresa un numero" number
10
+ read -p " Pais de origen" pais
11
+ read -p " Fecha de nacimiento" nacDate
12
+
13
+ # Validacion numero
14
+ if [[ $number =~ $regexNumber ]]; then
15
+ echo " Numero $number válido"
16
+ else
17
+ echo " Numero $numbmer inválido"
18
+ fi
19
+
20
+ # Validacion numero
21
+ if [[ $pais =~ $regexPais ]]; then
22
+ echo " Pais $pais válido"
23
+ else
24
+ echo " Pais $pais inválido"
25
+ fi
26
+
27
+ # Validacion numero
28
+ if [[ $nacDate =~ $regexNacimiento ]]; then
29
+ echo " Fecha $nacDate válido"
30
+ else
31
+ echo " Fecha $nacDate inválido"
32
+ fi
Original file line number Diff line number Diff line change
1
+ # ! /bin/bash
2
+
3
+ option=" Opcion"
4
+ result=" Result"
5
+ echo " $option and $result "
You can’t perform that action at this time.
0 commit comments