informatica:certificaciones:lpic:lpic-1:105_shells_and_shell_scripting
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
| informatica:certificaciones:lpic:lpic-1:105_shells_and_shell_scripting [2022/04/19 10:17] – [PARTE I] tempwin | informatica:certificaciones:lpic:lpic-1:105_shells_and_shell_scripting [2022/04/19 10:41] (actual) – [Test] tempwin | ||
|---|---|---|---|
| Línea 24: | Línea 24: | ||
| <code bash> | <code bash> | ||
| - | echo " | + | echo " |
| read filename | read filename | ||
| - | echo " | + | echo " |
| read path | read path | ||
| </ | </ | ||
| Línea 34: | Línea 34: | ||
| <code bash> | <code bash> | ||
| - | echo "Cuántos | + | echo "Número de ficheros |
| read num_files | read num_files | ||
| </ | </ | ||
| Línea 42: | Línea 42: | ||
| <code bash> | <code bash> | ||
| i=1 | i=1 | ||
| - | while [ $i -gt $num_files ] | + | while [ $i -le $num_files ] |
| do | do | ||
| touch $path/ | touch $path/ | ||
| Línea 54: | Línea 54: | ||
| #!/bin/bash | #!/bin/bash | ||
| - | echo " | + | echo " |
| read filename | read filename | ||
| - | echo " | + | echo " |
| read path | read path | ||
| - | echo "Cuántos | + | echo "Número de ficheros |
| read num_files | read num_files | ||
| i=1 | i=1 | ||
| - | while [ $i -gt $num_files ] | + | while [ $i -le $num_files ] |
| do | do | ||
| touch $path/ | touch $path/ | ||
| Línea 74: | Línea 74: | ||
| **Cree un script de shell que haga lo siguiente: | **Cree un script de shell que haga lo siguiente: | ||
| - | **1. mostrará una lista completa y completa (recursiva) del contenido de cualquier directorio que se le pase en la línea de comando** | + | **1. mostrará una lista completa y completa (recursiva) del contenido de cualquier directorio que se le pase en la línea de comando** |
| + | |||
| + | <code bash> | ||
| + | dir=$1 | ||
| + | |||
| + | find $dir -print | ||
| + | </ | ||
| **2. mostrará un mensaje de error si el parámetro que le das no es un directorio.** | **2. mostrará un mensaje de error si el parámetro que le das no es un directorio.** | ||
| + | |||
| + | <code bash> | ||
| + | if [ -d $dir ] | ||
| + | then | ||
| + | find $dir -print | ||
| + | else | ||
| + | echo "$dir no es un directorio" | ||
| + | fi | ||
| + | </ | ||
| **3. Probar el script para que muestre los resultados con un directorio válido y y forzar el error con un nombre de directorio no existente** | **3. Probar el script para que muestre los resultados con un directorio válido y y forzar el error con un nombre de directorio no existente** | ||
| + | |||
| + | Script completo: | ||
| + | |||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | |||
| + | dir=$1 | ||
| + | |||
| + | # Comprobar si es un directorio | ||
| + | if [ -d $dir ] | ||
| + | then | ||
| + | find $dir -print | ||
| + | else | ||
| + | echo "$dir no es un directorio" | ||
| + | exit 1 | ||
| + | fi | ||
| + | </ | ||
| + | |||
| + | ===== Test ===== | ||
| + | |||
| + | **Every shell script intended to run within a bash environment, | ||
| + | |||
| + | * ''#/ | ||
| + | * '' | ||
| + | * '' | ||
| + | * ''# | ||
| + | |||
| + | **Of the following conditional statements within a shell script, which one will test for the existence of a file called ' | ||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | **What user script (if it exists) is run, from a user's home directory, every time they log into a system? (select 2)** | ||
| + | |||
| + | * '' | ||
| + | * ''/ | ||
| + | * ''/ | ||
| + | * '' | ||
| + | |||
| + | **Which of the following special shells that, when assigned to a user account as the default shell, will prevent that account from being able to log in? (Choose the 2 correct answers)** | ||
| + | |||
| + | * '' | ||
| + | * ''/ | ||
| + | * ''/ | ||
| + | * ''/ | ||
| + | |||
| + | **Which of the following variable definitions will be available to subshells in the environment? | ||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * None of the Above | ||
| + | |||
informatica/certificaciones/lpic/lpic-1/105_shells_and_shell_scripting.1650356238.txt.gz · Última modificación: por tempwin
