Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2007
    Posts
    688

    save grep to txt file?

    I grepped an IP address on a domain log and it showed thousands of lines. How do I save this grep result to a txt file so I can send it to someone?

  2. #2
    Join Date
    Dec 2004
    Location
    Clemson
    Posts
    172
    I belive its
    grep (put your options) >> filename.txt
    Brett Meadors

  3. #3
    Join Date
    Nov 2001
    Location
    Philadelphia, Pa
    Posts
    949
    yeah.

    grep <options> search_term file > file_to_save.txt
    Or, use >> to append to a file.

  4. #4
    Join Date
    Jun 2002
    Posts
    1,376
    Adding a "> filename.txt" will write the file to filename.txt, completely overwriting whatever was already there.

    ">> filename.txt" will add it to the end of the file.

    This can be done with (most) anything on the command line that produces output (and isn't interactive): "uptime >> uptime.txt" or "lsof >> something.txt" works too.

  5. #5
    Join Date
    Apr 2006
    Location
    Phoenix
    Posts
    808
    A nice trick is once you have sent the output to a textfile do this:

    cat file.txt | grep -v stuffyoudontwant > file.txt

    This can help you start removing lines you dont want to drill down to what you do.
    Jordan Jacobs | VP, Products|SingleHop| JJ @SingleHop.com
    Managed Dedicated Servers | Bare-Metal Servers | Cloud Services

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •