Ir al contenido
  • +31 653-919-302
Cafayate.Net
  • 0
  • 0
  • Inicia sesión
  • Nederlands English (US) Español (AR)
  • Contáctanos
  • Inicio
  • Blog
  • Empleos
  • Contáctanos
Cafayate.Net
  • 0
  • 0
    • Inicio
    • Blog
    • Empleos
    • Contáctanos
  • +31 653-919-302
  • Nederlands English (US) Español (AR)
  • Inicia sesión
  • Contáctanos

How to find a word in text files from a directory

  • Todos los blogs
  • Tech Blog
  • How to find a word in text files from a directory
  • 5 de marzo de 2021 por
    Administrator
        Open a terminal.
        Install ack-grep by typing sudo apt-get install ack-grep
        Change to the directory you want to search under, and type

    ack-grep foo

      it lists out all the matches in all files under that directory.
        —
        If you don’t want to install additional software, you can simply use

    grep

        in the terminal. To recursively search through directories, you can use the

    -r

        option (see

    man grep

        for details). The syntax you are looking for is probably:
    grep -r "[STRING TO SEARCH FOR]" "[DIRECTORY TO SEARCH]"
    

    So, for instance if I want to search for the string “asdf” in all files in all subdirectories of “/tmp/testdir/” the command looks like this:

    grep -r "asdf" "/tmp/testdir/"
    

    The quotation marks are not strictly necessary, but if your string or directory path contains whitespaces, you otherwise would have to mask them using the \ character…

    en Tech Blog
    Duplicity Backup How to Ubuntu

    Diseñado para empresas

    Somos un equipo de personas apasionadas cuyo objetivo es mejorar la vida de todos a través de productos revolucionarios. Creamos grandes productos para resolver sus problemas empresariales. Nuestros productos están diseñados para pequeñas y medianas empresas dispuestas a optimizar su rendimiento.

    Contáctenos

    Plantexel
    Pedernera
    Salta Capital 
    Argenina

    • +31 653-919-302
    • [email protected]
    Síganos
    Copyright © Plantexel
    Nederlands | English (US) | Español (AR)