103.2 Process text streams using filters

Descripción

103.2 Process text streams using filters
Rolando Martinez
Mapa Mental por Rolando Martinez, actualizado hace más de 1 año
Rolando Martinez
Creado por Rolando Martinez hace más de 3 años
3
0

Resumen del Recurso

103.2 Process text streams using filters
  1. Send text files and output streams through text utility filters to modify the output using standard UNIX commands found in the GNU textutils package.
    1. bzcat cat cut head less md5sum nl od paste sed sha256sum sha512sum sort split tail tr uniq wc xzcat zcat
    2. Comando cat
      1. Type Cat Enter and random text
        1. cat > mytextfile (Graba)
          1. Hola Bienvenidos al Cumpleaños en Casa es un placer poder compartir con ustedes^C
          2. cat mytextfile (Visualiza)
            1. Hola Bienvenidos al Cumpleaños en Casa es un placer poder compartir con ustedes^
            2. cat mytextfile > mynewtextfile
              1. cat to direct its output to the mytextfile file
                1. diff mynewtextfile mytextfile
                  1. You can actually verify that these two files have the same content by performing a diff
                    1. echo 'This is my new line' >> mynewtextfile
                      1. diff mynewtextfile mytextfile
                        1. 4d3 < This is my new line
                  2. cat mytextfile | grep this
                    1. cat mytextfile | grep -i this
                  3. Processing Text Streams
                    1. vi ftu.txt
                      1. bzcat cat cut head less md5sum nl od paste sed sha256sum sha512sum sort split tail tr uniq wc xzcat zcat
                      2. cat ftu.txt | grep cat
                        1. bzcat cat xzcat zcat
                        2. grep cat ftu.txt
                          1. bzcat cat xzcat zcat
                          2. commands that handle compressed files
                            1. bzcat
                              1. bzip compresed files
                              2. xzcat
                                1. xz compresed Files
                                2. gzip
                                  1. gzip compresed files
                                    1. gzip ftu.txt
                                      1. ftu.txt.gz
                                        1. comprimir
                                        2. zcat ftu.txt.gz
                                          1. Visualizar
                                    2. Viewing a File in a Pager
                                      1. sudo cat /var/log/syslog
                                        1. sudo less /var/log/syslog
                                          1. sudo head /var/log/syslog
                                            1. sudo tail /var/log/syslog
                                              1. sudo tail -n 5 /var/log/syslog
                                              2. sudo head /var/log/syslog | nl
                                                1. sudo tail /var/log/syslog | wc -l
                                                2. The Basics of sed, the Stream Editor
                                                  1. zcat ftu.txt.gz | grep -v cat
                                                    1. gunzip ftu.txt.gz
                                                      1. sed -n /cat/p < ftu.txt
                                                        1. listar solo las líneas que contienen la cadena cat
                                                          1. <
                                                            1. redirige ftu a sed
                                                            2. /cat/
                                                              1. string to search
                                                              2. -n
                                                                1. La opción -n instruye a sed para que no produzca salida (a menos por las instrucciones posteriores del comando p)
                                                              3. sed /cat/d < ftu.txt
                                                                1. cut head less md5sum nl od paste sed sha256sum sha512sum sort split tail tr uniq wc
                                                                2. sed s/cat/dog/ < ftu.txt
                                                                  1. Change cat by dog
                                                                    1. sed -i.backup s/cat/dog/ ftu.txt
                                                                      1. Insertar
                                                                3. Ensuring Data Integrity
                                                                  1. los archivos de imagen del instalador de Debian están acompañados por archivos de texto que contienen sumas de verificación de los archivos de los diversos algoritmos (MD5, SHA1, SHA256 y SHA512).
                                                                    1. [SUM] SHA512SUMS [CRT] SHA512SUMS.sign [ISO]debian-10.1.0-amd64-netinst.iso
                                                                    2. sha256sum ftu.txt
                                                                      1. 45452304fc26999a715652543c352e5fc7ee0c1b9deac6f57542ec91daf261c ftu.txt
                                                                      2. sha256sum ftu.txt > sha256.txt
                                                                        1. sha256sum -c sha256.txt ftu.txt: OK
                                                                          1. echo "new entry" >> ftu.txt
                                                                            1. la suma no coincide
                                                                        2. Looking Deeper into Files
                                                                          1. od
                                                                            1. od ftu.txt
                                                                              1. 0000000 075142 060543 005164 060543 005164 072543 005164 062550 0000020 062141
                                                                                1. octal
                                                                                2. od -x ftu.txt
                                                                                  1. Hexadecimal
                                                                                  2. od -c ftu.txt
                                                                                    1. Caracteres
                                                                                    2. od -An -c ftu.txt
                                                                                      1. delete desplazamiento de bytes
                                                                                      2. se usa para depurar aplicaciones y varios archivos
                                                                                    3. Preguntas y Respuestas
                                                                                      1. 1.- Usando los comandos sed, grep y wc muestre cuántos procesadores tiene.
                                                                                        1. sed -n /processor/p /proc/cpuinfo | wc -l
                                                                                          1. grep processor /proc/cpuinfo | wc -l
                                                                                          2. 2.- Explorar /etc/passwd
                                                                                            1. 1.- ¿¿Qué usuarios tienen acceso a un shell Bash??
                                                                                              1. grep /bin/bash /etc/passwd
                                                                                                1. grep ":/bin/bash$" /etc/passwd | cut -d: -f1
                                                                                              2. 2.- ¿Cuántos usuarios no tienen acceso al shell?
                                                                                                1. grep /bin/false /etc/passwd
                                                                                                2. 3.- Cuántos usuarios y grupos existen en su sistema (recuerde: use solo el archivo /etc/passwd)?
                                                                                                  1. a.- cut -d: -f3 /etc/passwd | wc -l
                                                                                                    1. b.- cut -d: -f3 /etc/passwd |sort -u | wc -l
                                                                                                    2. 4.- Muestre solo la primera línea, la última línea y la décima línea de su archivo /etc/passwd.
                                                                                                      1. sed -n -e '1'p -e '10'p -e '$'p /etc/passwd
                                                                                                        1. Recuerde que el parámetro -n le dice a sed que no imprima nada más que lo especificado por el comando p. El signo de dólar ($) usado aquí es una expresión regular que significa la última línea del archivo.
                                                                                                      2. 5.- Liste todos los usuarios en el grupo 1000
                                                                                                        1. sed -n /:1000:[A-Z]/p /etc/passwd
                                                                                                        2. 6.- Enumere solo los nombres completos de todos los usuarios de este grupo (use sed y cut):
                                                                                                          1. sed -n /:1000:[A-Z]/p mypasswd | cut -d: -f5
                                                                                                            1. sed -n /:1000:[A-Z]/p mypasswd | cut -d: -f5 | cut -d, -f1
                                                                                                          2. 7.- utilizando el archivo mypasswd de los ejercicios anteriores, idee un comando Bash que seleccionará a una persona de la Oficina Principal para ganar un concurso de rifas.
                                                                                                            1. sed -n /Main\ Office/p mypasswd | cut -d: -f5 | cut -d, -f1 | sort -R | head -1
                                                                                                          3. 8.- ¿Cuántas personas trabajan en Recursos Humanos, Ingeniería y Cuentas por pagar?
                                                                                                            1. sed -n /Main\ Office/p mypasswd | cut -d: -f5 | cut -d, -f2 | uniq -c
                                                                                                              1. -c
                                                                                                                1. Cuenta las ocurrencias
                                                                                                            2. ¿9.- Preparar el sigueinte archivo El contenido del archivo tendrá el siguiente formato:?
                                                                                                              1. sed -n /Main Office/p mypasswd | cut -d: -f5 | cut -d" " -f1 > firstname
                                                                                                                1. sed -n /Main Office/p mypasswd | cut -d: -f5 | cut -d" " -f2 | cut -d, -f1 > lastname
                                                                                                                2. ¿10.- Departamento en que trabaja cada empleado?
                                                                                                                  1. sed -n /Main Office/p mypasswd | cut -d: -f5 | cut -d, -f2 > department
                                                                                                                  2. 11.- ¿Solucion Final ?
                                                                                                                    1. cat firstname lastname department
                                                                                                                      1. paste firstname lastname department
                                                                                                                        1. paste  firstname lastname department | tr '\t > names.csv
                                                                                                                          1. paste -d, firstname lastname department
                                                                                                                            1. sed -n /Main Office/p mypasswd | cut -d: -f5 | cut -d, -f1,2 | tr ' ' , > names2.csv
                                                                                                                        2. Preguntas y Respuestas
                                                                                                                          1. 1.- ¿Cómo podemos asegurar la integridad del archivo names.csv usando md5sum?
                                                                                                                            1. md5sum names.csv
                                                                                                                              1. b42d753fe22b94bd3915272f127acf4c names.csv
                                                                                                                                1. message digest
                                                                                                                              2. sha256sum names.csv
                                                                                                                                1. b04766220f36d0cce33afe23fa41f53c6eb685646d2a9e1f7d5fe9aed740b950 names2.csv
                                                                                                                                  1. message digest
                                                                                                                              3. 2.- Si el archivo se ha modificado ligeramente, el resumen del mensaje será completamente diferente. Solo para demostrarlo, edite names.csv y cambie James a Jones como se muestra aquí:
                                                                                                                                1. sed -i.backup s/James/Jones/ names.csv
                                                                                                                                  1. md5sum names.csv
                                                                                                                                    1. f44a0d68cb480466099021bf6d6d2e65 names.csv
                                                                                                                                      1. message digest
                                                                                                                                2. 3.- ¿Como dividir un archivo de varias lineas en pedazos de 100 lineas?
                                                                                                                                  1. download the file
                                                                                                                                    1. wget https://www.gutenberg.org/files/50461/50461-0.txt
                                                                                                                                    2. how many have line
                                                                                                                                      1. cat 50461-0.txt |wc -l
                                                                                                                                      2. dividir en trozos de 100 lineas
                                                                                                                                        1. split -l 100 -d 50461-0.txt melville
                                                                                                                                          1. melville00 ....... melvillenn
                                                                                                                                            1. melville es el prefijo
                                                                                                                                              1. -l 100 numero de lineas
                                                                                                                                                1. -d 50461-0.txt
                                                                                                                                                  1. Numere los archivos usando l prefijo melville
                                                                                                                                            2. Trabajando con la salida del comando ls en /etc
                                                                                                                                              1. ls -l /etc | tr -s ' ' ,
                                                                                                                                                1. -s: suprime multiples espacios en banco en la saida
                                                                                                                                                2. ls -l /etc | tr -s ' '
                                                                                                                                                  1. ls -l /etc | tr -s ' ' | cut -d" " -f9
                                                                                                                                                    1. Nombre archivo
                                                                                                                                                    2. ls -l /etc | tr -s ' ' | cut -d" " -f9,3
                                                                                                                                                      1. nombre de archivo y dueño
                                                                                                                                                      2. $ ls -l /etc | grep ^d | tr -s ' ' | cut -d" " -f9,3
                                                                                                                                                        1. Nombres de carpetas y dueño
                                                                                                                                                        2. tail -f /var/log/syslog | grep -i 'product\:\|blocks\|manufacturer'
                                                                                                                                                          1. SEguirle la pista a message con tail
                                                                                                                                                    Mostrar resumen completo Ocultar resumen completo

                                                                                                                                                    Similar

                                                                                                                                                    Revolución Francesa
                                                                                                                                                    Diego Santos
                                                                                                                                                    Factorización
                                                                                                                                                    Nancy Guzman
                                                                                                                                                    ORIGEN DE LOS LOGARITMOS
                                                                                                                                                    Hugo Fernando
                                                                                                                                                    La Primera Guerra Mundial
                                                                                                                                                    juanmadj
                                                                                                                                                    SOSTENIBILIDAD
                                                                                                                                                    Carlos Párraga
                                                                                                                                                    ATMÓSFERA
                                                                                                                                                    Ulises Yo
                                                                                                                                                    50 Things To Do Between Your Study Sessions
                                                                                                                                                    Elaine del Valle
                                                                                                                                                    mapa conceptual
                                                                                                                                                    giovanny toro
                                                                                                                                                    REPRODUCTION I
                                                                                                                                                    Nuria Prado Álvarez