Docsity

Practicas de Software, Ejercicios de Ingeniería Infórmatica

Toggle sidebar
bg1
Portafolios Prácticas Jesús García Godoy –Fundamentos del Software
24-1-2012 Documento v1.0 Página 1 de 64
r
Manual para la implantación de @ries
Implantación de @ries
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40

Vista previa parcial del texto

¡Descarga Practicas de Software y más Ejercicios en PDF de Ingeniería Infórmatica solo en Docsity!

Portafolios Prácticas Jesús García Godoy – Fundamentos del Software

r

Manual para la implantación de @ries

Implantación de @ries

Portafolios Prácticas Jesús García Godoy – Fundamentos del Software

  • 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

Sesion 2

EJERCICIO 1

Crea el siguiente árbol de directorios a partir de tu directorio de usuario (donde usuario representa tu nombre de usuario o login en el sistema operativo). Crea también los ficheros vacíos pg1 y ma51ik en los directorios que se indican en la ilustración:

mkdir ug touch pg cd ug mkdir ee51vn touch ma51ik cd ee51vn mkdir docs pics

EJERCICIO 2

Mueve el directorio pics dentro del directorio ug1. Renombra finalmente dicho directorio a imagenes. Copia el directorio docs dentro de ug.

cd $HOME mv ./ug1/ee51vn/pics ./ug1/imagenes cp - r ./ug1/ee51vn/docs ./ug

EJERCICIO 3

Liste los archivos que estén en su directorio actual y fíjese en alguno que no disponga de la fecha actualizada, es decir, el día de hoy. Ejecute la orden touch sobre dicho archivo y observe qué sucede sobre la fecha del citado archivo cuando se vuelva a listar.

ls - lF touch ejemplo.txt

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

b) las 5 últimas líneas.

tail - n 10 jamon.txt

EJERCICIO 8

Ordene el contenido de un archivo de texto según diversos criterios de ordenación.

Por orden alfabetico:

sort jamon.txt

Por orden numerico:

sort - n jamon.txt

Al reves:

sort - r jamon.txt

Aleatoriamente:

sort - R jamon.txt

EJERCICIO 9

¿Cómo puedes ver el contenido de todos los archivos del directorio actual que terminen en .txt o .c?

ls - l ./*.{txt,c}

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

Sesion 4

EJERCICIO 1

Escriba, al menos, cinco variables de entorno junto con el valor que tienen.

HOME=/home/superjes USERNAME=superjes LANGUAGE=es_ES:en LOGNAME=superjes DESKTOP_SESSION=gnome

EJERCICIO 2

Ejecute las órdenes del cuadro e indique qué ocurre y cómo puede resolver la situación para que la

variable NOMBRE se reconozca en el shell hijo.

$ export NOMBRE=FS $ echo $NOMBRE $ FS $ bash $ echo $NOMBRE $ FS

EJERCICIO 3

Compruebe qué ocurre en las expresiones del ejemplo anterior si se quitan las comillas dobles del

final y se ponen después de los dos puntos. ¿Qué sucede si se sustituyen las comillas dobles por

comillas simples?

-Si se ponen las dobles comillas después de los 2 puntos pasa que todo sale a continuación de lo

anterior sin saltos de línea , con lo que no queda muy visual:

$ echo "Los archivos que hay en el directorio son:" $(ls - l)

Los archivos que hay en el directorio son: total 60 drwxr-xr-x 2 superjes superjes 4096 2011- 10 - 11 08:50 Descargas drwxr-xr-x 2 superjes superjes 4096 2011- 09 - 28 01:07 Documentos - rw-r--r-- 1 superjes superjes 9 2011- 10 - 11 09:15 ej31 - rw-r--r-- 1 [...]

-Si se sustituyen las comillas dobles por comillas simples pasa que se muestra literalmente lo que hay

dentro de ellas, sin ejecutar ningún comando que contenga.

$ echo 'Los archivos que hay en el directorio son ls - l'

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

EJERCICIO 11

Complete la información de find y grep utilizando para ello la orden man.

man find:

  • P Never follow symbolic links. This is the default behaviour. When find examines or prints information a file, and the file is a symbolic link, the information used shall be taken from the properties of the symbolic link itself.
  • L Follow symbolic links. When find examines or prints information about files, the information used shall be taken from the prop‐ erties of the file to which the link points, not from the link itself (unless it is a broken symbolic link or find is unable to examine the file to which the link points). Use of this option implies - noleaf. If you later use the - P option, - noleaf will still be in effect. If - L is in effect and find discovers a symbolic link to a subdirectory during its search, the subdirec‐ tory pointed to by the symbolic link will be searched.

When the - L option is in effect, the - type predicate will always match against the type of the file that a symbolic link points to rather than the link itself (unless the symbolic link is bro‐ ken). Using - L causes the - lname and - ilname predicates always to return false.

  • H Do not follow symbolic links, except while processing the com‐ mand line arguments. When find examines or prints information about files, the information used shall be taken from the prop‐ erties of the symbolic link itself. The only exception to this behaviour is when a file specified on the command line is a sym‐ bolic link, and the link can be resolved. For that situation, the information used is taken from whatever the link points to (that is, the link is followed). The information about the link itself is used as a fallback if the file pointed to by the sym‐ bolic link cannot be examined. If - H is in effect and one of the paths specified on the command line is a symbolic link to a directory, the contents of that directory will be examined (though of course - maxdepth 0 would prevent this).
  • D debugoptions Print diagnostic information; this can be helpful to diagnose problems with why find is not doing what you want. The list of debug options should be comma separated. Compatibility of the debug options is not guaranteed between releases of findutils. For a complete list of valid debug options, see the output of find - D help. Valid debug options include

help Explain the debugging options

tree Show the expression tree in its original and optimised form.

stat Print messages as files are examined with the stat and

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

needed when searching filesystems that do not follow the Unix directory-link convention, such as CD-ROM or MS-DOS filesystems or AFS volume mount points. Each directory on a normal Unix filesystem has at least 2 hard links: its name and its .' entry. Additionally, its subdirectories (if any) each have a..' entry linked to that directory. When find is examining a directory, after it has statted 2 fewer subdirectories than the directory's link count, it knows that the rest of the entries in the directory are non-directories (`leaf' files in the directory tree). If only the files' names need to be examined, there is no need to stat them; this gives a significant increase in search speed.

  • regextype type Changes the regular expression syntax understood by - regex and
    • iregex tests which occur later on the command line. Currently- implemented types are emacs (this is the default), posix-awk, posix-basic, posix-egrep and posix-extended.
  • version, --version Print the find version number and exit.
  • warn, - nowarn Turn warning messages on or off. These warnings apply only to the command line usage, not to any conditions that find might encounter when it searches directories. The default behaviour corresponds to - warn if standard input is a tty, and to - nowarn otherwise.
  • xdev Don't descend directories on other filesystems.

man grep:

OPTIONS

Generic Program Information --help Print a usage message briefly summarizing these command-line options and the bug-reporting address, then exit.

- V, --version Print the version number of grep to the standard output stream. This version number should be included in all bug reports (see below).

Matcher Selection

- E, --extended-regexp Interpret PATTERN as an extended regular expression (ERE, see below). (-E is specified by POSIX.)

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.

Portafolios Prácticas Jesús García Godoy – Fundamentos del Software

- H, --with-filename Print the file name for each match. This is the default when _there is more than one file to search.

  • h, --no-filename_ Suppress the prefixing of file names on output. This is the default when there is only one file (or only standard input) to search.

--label=LABEL Display input actually coming from standard input as input coming from file LABEL. This is especially useful when implementing tools like zgrep, e.g., gzip - cd foo.gz | grep --label=foo - H something. See also the - H option.

- n, --line-number Prefix each line of output with the 1-based line number within _its input file. (-n is specified by POSIX.)

  • T, --initial-tab_ Make sure that the first character of actual line content lies on a tab stop, so that the alignment of tabs looks normal. This is useful with options that prefix their output to the actual content: - H,-n, and - b. In order to improve the probability that lines from a single file will all start at the same column, this also causes the line number and byte offset (if present) to _be printed in a minimum size field width.
  • u, --unix-byte-offsets_ Report Unix-style byte offsets. This switch causes grep to report byte offsets as if the file were a Unix-style text file, i.e., with CR characters stripped off. This will produce results identical to running grep on a Unix machine. This option has no effect unless - b option is also used; it has no _effect on platforms other than MS-DOS and MS-Windows.
  • Z, --null_ Output a zero byte (the ASCII NUL character) instead of the character that normally follows a file name. For example, grep - lZ outputs a zero byte after each file name instead of the usual newline. This option makes the output unambiguous, even in the presence of file names containing unusual characters like newlines. This option can be used with commands like find - print0, perl - 0, sort - z, and xargs - 0 to process arbitrary file names, even those that contain newline characters.

Context Line Control

- A NUM, --after-context=NUM Print NUM lines of trailing context after matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the - o or --only-matching _option, this has no effect and a warning is given.

  • B NUM, --before-context=NUM_ Print NUM lines of leading context before matching lines. Places a line containing a group separator (--) between