¡Descarga soluciones de ejercicios de practicas fs y más Ejercicios en PDF de Ingeniería Infórmatica solo en Docsity!
Descargado en:
patatabrava .com
FUNDAMENTOS DEL SOFTWARE (UGR)
PRACTICAS DE SOFTWARE
, ALUMNO 12-
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
r
Manual para la implantación de @ries
Implantación de @ries
- Sesion Indice
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Sesion
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Sesion
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Sesion
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicios s5_Complementos.txt
- Sesion
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Sesion
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicios adicionales
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Sesion
- Ejercicio
- Ejercicio Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Sesion
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Sesion
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
- Ejercicio
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
ls - lF (la fecha se ha actualizado)
EJERCICIO 4
La organización del espacio en directorios es fundamental para poder localizar fácilmente aquello
que estemos buscando. En ese sentido, realice las siguientes acciones dentro de su directorio home
(es el directorio por defecto sobre el que trabajamos al entrar en el sistema):
a) Obtener en nombre de camino absoluto (pathname absoluto) de tu directorio home. ¿Es
el mismo que el de tu compañero/a?
echo $HOME (no es el mismo que el compañero)
b) Crear un directorio para cada asignatura en la que se van a realizar prácticas de
laboratorio y, dentro de cada directorio, nuevos directorios para cada una de las prácticas
realizadas hasta el momento.
mkdir FS CA ALEM FP FFT mkdir FS/practica1 FS/pratica2 FS/practica
c) Dentro del directorio de la asignatura fundamentos del software (llamado FS) y dentro del
directorio creado para esta sesión, copiar los archivos host y passwd que se encuentran
dentro del directorio /etc.
cp /etc/hosts $HOME/FS cp /etc/passwd $HOME/FS
d) Mostrar el contenido de cada uno de los archivos.
cat FS/hosts cat FS/passwd
EJERCICIO 5
Desplacémonos hasta el directorio /bin , genere los siguientes listados de archivos (siempre de la forma más
compacta y utilizando los metacaracteres apropiados):
cd /bin
a) Todos los archivos que contengan sólo cuatro caracteres en su nombre.
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
ls - l ????
b) Todos los archivos que comiencen por los caracteres d , f.
ls - l [df]*
c) Todos los archivos que comiencen por las parejas de caracteres sa , se , ad.
ls - l {sa,se,ad}*
d) Todos los archivos que comiencen por t y acaben en r.
ls - l t*r
EJERCICIO 6
Liste todos los archivos que comiencen por tem y terminen por .gz o .zip :
a) de tu directorio home
ls - l ~/tem*.{gz,zip}
b) del directorio actual
ls - l ./tem*.{gz,zip}
c) ¿hay alguna diferencia en el resultado de su ejecución? Explique el por qué si o el por qué no.
Si, uno usa rutas absolutas(aunque abreviada) y el otro no
EJERCICIO 7
Muestre del contenido de un archivo regular que contenga texto:
a) las 10 primeras líneas.
head - n 5 jamon.txt
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
Sesion 3
EJERCICIO 1
Se debe utilizar solamente una vez la orden chmod en cada apartado. Los cambios se harán en un
archivo concreto del directorio de trabajo (salvo que se indique otra cosa). Cambiaremos uno o
varios permisos en cada apartado (independientemente de que el archivo ya tenga o no dichos
permisos) y comprobaremos que funciona correctamente:
- Dar permiso de ejecución al “resto de usuarios”.
chmod o+x jamon.txt
- Dar permiso de escritura y ejecución al “grupo”.
chmod g+wx jamon.txt
- Quitar el permiso de lectura al “grupo” y al “resto de usuarios”.
chmod go-r jamon.txt
- Dar permiso de ejecución al “propietario” y permiso de escritura el “resto de usuarios”.
chmod u+x,o+w jamon.txt
- Dar permiso de ejecución al “grupo” de todos los archivos cuyo nombre comience con la letra “e”.
Nota: Si no hay más de dos archivos que cumplan esa condición, se deberán crear archivos que
empiecen con “e” y/o modificar el nombre de archivos ya existentes para que cumplan esa
condición.
chmod g+x e*
EJERCICIO 2
Utilizando solamente las órdenes de la sesión anterior y los metacaracteres de redirección de salida:
* Crear un archivo llamado ej31 , que contendrá el nombre de los archivos del directorio padre del
directorio de trabajo.
ls $HOME/.. > ej
* Crear un archivo llamado ej32 , que contendrá las dos últimas líneas del archivo creado en el
ejercicio anterior.
tail - n 2 ej31 > ej
* Añadir al final del archivo ej32 , el contenido del archivo ej.
cat ej31 >> ej
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
EJERCICIO 3
Utilizando el metacarácter de creación de cauces y sin utilizar la orden cd:
* Mostrar por pantalla, el listado (en formato largo) de los últimos 6 archivos del directorio padre en
el directorio de trabajo.
ls - l $HOME|tail - n 6
* La orden wc muestra por pantalla el número de líneas, palabras y caracteres de un archivo
(consulta la orden man para conocer más sobre ella). Utilizando dicha orden, mostrar por pantalla el
número de caracteres (sólo ese número) de los archivos del directorio de trabajo que comiencen por
los caracteres “e” o “f”.
wc - m $HOME/[ef]*
EJERCICIO 4
Resuelva cada uno de los siguientes apartados.
a) Crear un archivo llamado ejercicio1, que contenga las 17 últimas líneas del texto que proporciona
la orden man para la orden chmod (se debe hacer en una única línea de órdenes y sin utilizar el
metacarácter “;” ).
man chmod|tail - n 17 > ejercicio
b) Al final del archivo ejercicio1, añadir la ruta completa del directorio de trabajo actual.
pwd >> ejercicio
c) Usando la combinación de órdenes mediante paréntesis, crear un archivo llamado ejercicio3 que
contendrá el listado de usuarios conectados al sistema (orden who) y la lista de archivos del
directorio actual.
(who; ls - l) > ejercicio
d) Añadir, al final del archivo ejercicio3, el número de líneas, palabras y caracteres del archivo
ejercicio1. Asegúrese de que, por ejemplo, si no existiera ejercicio1, los mensajes de error también se
añadieran al final de ejercicio3.
wc ejercicio1 &>> ejercicio
e) Con una sola orden chmod, cambiar los permisos de los archivos ejercicio1 y ejercicio3, de forma
que se quite el permiso de lectura al “grupo” y se dé permiso de ejecución a las tres categorías de
usuarios.
chmod g-w,ugo+x ejercicio{1,3}
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
Los archivos que hay en el directorio son ls - l
EJERCICIO 4
Pruebe la siguiente asignación. ¿Qué ha ocurrido?
Ha ocurrido que como no hemos usado la orden "expr", no se reconoce el símbolo de la suma.
EJERCICIO 5
Construya un guion que acepte como argumento una cadena de texto (por ejemplo, su nombre) y
que visualice en pantalla la frase Hola y el nombre dado como argumento.
#!/bin/bash echo "Hola $1"
EJERCICIO 6
Varíe el guion anterior para que admita una lista de nombres.
#!/bin/bash echo "Hola $@"
EJERCICIO 7
Cree tres variables llamadas VAR1, VAR2 y VAR3 con los siguientes valores respectivamente “hola”,
“adios” y “14”.
VAR1=hola VAR2=adios VAR3=
a) Imprima los valores de las tres variables en tres columnas con 15 caracteres de ancho.
printf "%15s %15s %15d\n" $VAR1 $VAR2 $VAR
b) ¿Son variables locales o globales?
- Son locales
c) Borre la variable VAR2.
unset VAR
d) Abra otra ventana de tipo terminal, ¿puede visualizar las dos variables restantes?
- No, porque eran variables locales, sólo se podían ver en el terminal anterior.
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
e) Cree una variable de tipo vector con los valores iniciales de las tres variables.
vector=(hola adios 14)
f) Muestre el segundo elemento del vector creado en el apartado e.
echo ${vector[1]}
EJERCICIO 8
Cree un alias que se llame ne (nombrado así para indicar el número de elementos) y que devuelva el
número de archivos que existen en el directorio actual. ¿Qué cambiaría si queremos que haga lo
mismo pero en el directorio home correspondiente al usuario que lo ejecuta?
alias ne='ls .|wc - l'
Para que sea del directorio home del usuario que lo ejecuta:
alias ne='ls $HOME|wc - l'
EJERCICIO 9
Indique la línea de orden necesaria para buscar todos los archivos a partir del directorio home que
tengan un tamaño menor de un bloque. ¿Cómo la modificaría para que además imprima el resultado
en un archivo que se cree dentro del directorio donde nos encontremos y que se llame archivosP?
find /home - size - 1
Para que se guarde en un archivo del directorio actual:
find /home - size - 1 >> ./archivosP
EJERCICIO 10
Indique cómo buscaría todos aquellos archivos del directorio actual que contengan la palabra
“ejemplo”.
find ./ejemplo
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
lstat system calls. The find program tries to minimise such calls.
opt Prints diagnostic information relating to the optimisa‐ tion of the expression tree; see the - O option.
rates Prints a summary indicating how often each predicate suc‐ ceeded or failed.
- Olevel Enables query optimisation. The find program reorders tests to speed up execution while preserving the overall effect; that is, predicates with side effects are not reordered relative to each other. The optimisations performed at each optimisation level are as follows.
0 Equivalent to optimisation level 1.
1 This is the default optimisation level and corresponds to the traditional behaviour. Expressions are reordered so that tests based only on the names of files (for example
- name and - regex) are performed first.
2 Any - type or - xtype tests are performed after any tests based only on the names of files, but before any tests that require information from the inode. On many modern versions of Unix, file types are returned by readdir() and so these predicates are faster to evaluate than pred‐ icates which need to stat the file first.
3 At this optimisation level, the full cost-based query optimiser is enabled. The order of tests is modified so that cheap (i.e. fast) tests are performed first and more expensive ones are performed later, if necessary. Within each cost band, predicates are evaluated earlier or later according to whether they are likely to succeed or not. For - o, predicates which are likely to succeed are evalu‐ ated earlier, and for - a, predicates which are likely to fail are evaluated earlier.
- d A synonym for - depth, for compatibility with FreeBSD, NetBSD, MacOS X and OpenBSD.
- daystart Measure times (for - amin, - atime, - cmin, - ctime, - mmin, and
- mtime) from the beginning of today rather than from 24 hours ago. This option only affects tests which appear later on the command line.
- depth Process each directory's contents before the directory itself. The - delete action also implies - depth.
- follow
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
Deprecated; use the - L option instead. Dereference symbolic links. Implies - noleaf. The - follow option affects only those tests which appear after it on the command line. Unless the - H or - L option has been specified, the position of the - follow option changes the behaviour of the - newer predicate; any files listed as the argument of - newer will be dereferenced if they are symbolic links. The same consideration applies to - newerXY,
- anewer and - cnewer. Similarly, the - type predicate will always match against the type of the file that a symbolic link points to rather than the link itself. Using - follow causes the - lname and - ilname predicates always to return false.
- help, --help Print a summary of the command-line usage of find and exit.
- ignore_readdir_race Normally, find will emit an error message when it fails to stat a file. If you give this option and a file is deleted between the time find reads the name of the file from the directory and the time it tries to stat the file, no error message will be issued. This also applies to files or directories whose names are given on the command line. This option takes effect at the time the command line is read, which means that you cannot search one part of the filesystem with this option on and part of it with this option off (if you need to do that, you will need to issue two find commands instead, one with the option and one without it).
- maxdepth levels Descend at most levels (a non-negative integer) levels of direc‐ tories below the command line arguments. - maxdepth 0 means only apply the tests and actions to the command line arguments.
- mindepth levels Do not apply any tests or actions at levels less than levels (a non-negative integer). - mindepth 1 means process all files except the command line arguments.
- mount Don't descend directories on other filesystems. An alternate name for - xdev, for compatibility with some other versions of find.
- noignore_readdir_race Turns off the effect of - ignore_readdir_race.
- noleaf Do not optimize by assuming that directories contain 2 fewer subdirectories than their hard link count. This option is
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
- F, --fixed-strings Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by _POSIX.)
- G, --basic-regexp_ Interpret PATTERN as a basic regular expression (BRE, see _below). This is the default.
- P, --perl-regexp_ Interpret PATTERN as a Perl regular expression. This is highly experimental and grep - P may warn of unimplemented features.
Matching Control
- e PATTERN, --regexp=PATTERN Use PATTERN as the pattern. This can be used to specify multiple search patterns, or to protect a pattern beginning with _a hyphen (-). (-e is specified by POSIX.)
- f FILE, --file=FILE_ Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is _specified by POSIX.)
- i, --ignore-case_ Ignore case distinctions in both the PATTERN and the input _files. (-i is specified by POSIX.)
- v, --invert-match_ Invert the sense of matching, to select non-matching lines. (-v _is specified by POSIX.)
- w, --word-regexp_ Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the _underscore.
- x, --line-regexp_ Select only those matches that exactly match the whole line. _(-x is specified by POSIX.)
- y Obsolete synonym for - i._
General Output Control
- c, --count Suppress normal output; instead print a count of matching lines for each input file. With the - v, --invert-match option (see below), count non-matching lines. (-c is specified by POSIX.)
--color[=WHEN], --colour[=WHEN] Surround the matched (non-empty) strings, matching lines,
Portafolios Prácticas Jesús García Godoy – Fundamentos del Software
context lines, file names, line numbers, byte offsets, and separators (for fields and groups of context lines) with escape sequences to display them in color on the terminal. The colors are defined by the environment variable GREP_COLORS. The deprecated environment variable GREP_COLOR is still supported, but its setting does not have priority. WHEN is never, always, or auto.
- L, --files-without-match Suppress normal output; instead print the name of each input file from which no output would normally have been printed. The _scanning will stop on the first match.
- l, --files-with-matches_ Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match. (-l is specified by _POSIX.)
- m NUM, --max-count=NUM_ Stop reading a file after NUM matching lines. If the input is standard input from a regular file, and NUM matching lines are output, grep ensures that the standard input is positioned to just after the last matching line before exiting, regardless of the presence of trailing context lines. This enables a calling process to resume a search. When grep stops after NUM matching lines, it outputs any trailing context lines. When the - c or --count option is also used, grep does not output a count greater than NUM. When the - v or --invert-match option is also _used, grep stops after outputting NUM non-matching lines.
- o, --only-matching_ Print only the matched (non-empty) parts of a matching line, _with each such part on a separate output line.
- q, --quiet, --silent_ Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected. Also see the - s or --no-messages option. _(-q is specified by POSIX.)
- s, --no-messages_ Suppress error messages about nonexistent or unreadable files. Portability note: unlike GNU grep, 7th Edition Unix grep did not conform to POSIX, because it lacked - q and its - s option behaved like GNU grep's - q option. USG-style grep also lacked - q but its - s option behaved like GNU grep. Portable shell scripts should avoid both - q and - s and should redirect standard and error output to /dev/null instead. (-s is specified by POSIX.)
Output Line Prefix Control
- b, --byte-offset Print the 0-based byte offset within the input file before each line of output. If - o (--only-matching) is specified, print the offset of the matching part itself.