grep

This is a discussion on grep within the C Programming forums, part of the General Programming Boards category; how can i grep all the files BUT a string without .txt within it. (i grep everything but the files ...

  1. #1
    Unregistered
    Guest

    Question grep

    how can i grep all the files BUT a string without .txt within it.
    (i grep everything but the files with a specific ending(ie) .txt)

    tnx

  2. #2
    Unregistered
    Guest
    You might want to try the following version of grep, it should find all instances except what is specified.

    egrep -v *.txt

  3. #3
    B26354 Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633

    Re: grep

    Originally posted by Unregistered
    (i grep everything but the files with a specific ending(ie) .txt
    Hopefully I haven't misunderstood your question. Here is how to grep for the phrase Hello World from every file in your (or in this case, my) home directory except for the files that end in .txt:
    Code:
    find /home/jdeckard ! -name "*.txt" -exec grep "Hello World" {} \;
    This tells find to start looking for any file in /home/jdeckard that does not (!) end in .txt. Everytime a file is found that does not end in .txt, grep is executed. Grep looks for "Hello World" in the file {}. Where find is concerned, {} represents the current filename. The escaped semi-colon on the end is important.

    This isn't really a C question, so you may be better served by asking around on the *nix newsgroups.

    Cheers,
    Jason Deckard

  4. #4
    Unregistered
    Guest

    grep

    thanks jason

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. programming with grep
    By George2 in forum Tech Board
    Replies: 4
    Last Post: 11-18-2006, 03:30 AM
  2. simple grep problem
    By cdave in forum Windows Programming
    Replies: 7
    Last Post: 12-29-2005, 05:48 PM
  3. Grep Last Pattern Output
    By cfriend in forum Linux Programming
    Replies: 1
    Last Post: 09-18-2004, 11:14 AM
  4. Grep
    By cfriend in forum Linux Programming
    Replies: 3
    Last Post: 09-17-2004, 06:34 AM
  5. Grep
    By Adam in forum C Programming
    Replies: 0
    Last Post: 06-07-2002, 07:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21