Programers and unix admins:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zester
    Confirmed User
    • Jul 2003
    • 5344

    #1

    Programers and unix admins:

    ok.

    here is a bash command line question:

    let's say I'm currently in a directory call "members".
    in the "members" directory there are sub-directories: "john", "Tami", "Bob".
    inside each of those sub directories there are a few .html files, one of them is "index.html".

    what I want is to scan the content of those "index.html" files in every sub-directory ("john", "Tami", "Bob")
    and print out the "index.html" files that DO NOT contain the word "myimage.gif".

    how do I do that? this is what I tried and failed:

    find . -type f -name "index.html" | xargs grep -l -v 'myimage.gif'
    find . -type f -name "index.html" | xargs grep -l -v "myimage.gif"
    find . -type f -name "index.html" | xargs grep -l -v 'myimage\.gif'


    anyone know a good unix forum I can ask this question?
    * Mainstream ? $65 per sale
    * new male contraception
  • V_RocKs
    Damn Right I Kiss Ass!
    • Nov 2003
    • 32449

    #2
    find . -type f -name "index.html" | xargs cat|grep -l -v 'myimage.gif'

    Comment

    • V_RocKs
      Damn Right I Kiss Ass!
      • Nov 2003
      • 32449

      #3
      find ./ -type f -name index*.html|xargs grep -l -v 'myimage.gif'

      Comment

      • V_RocKs
        Damn Right I Kiss Ass!
        • Nov 2003
        • 32449

        #4
        The last one worked just fine for me.
        What is your error if any?

        Comment

        • rivalen
          Registered User
          • Apr 2003
          • 8

          #5
          find . -name "index.html" -exec grep -qsv "myimage.gif" '{}' \; -print

          Comment

          • NiteRain
            Confirmed User
            • Jul 2002
            • 600

            #6
            You are looking for something like this in BASH:

            for i in `find . -type f -name "index.html"`; do if ( grep -v "myimage\.gif" $i >/dev/null ); then echo $i; fi ; done
            AIM: PerlScriptor

            Comment

            • NiteRain
              Confirmed User
              • Jul 2002
              • 600

              #7
              Originally posted by V_RocKs
              find ./ -type f -name index*.html|xargs grep -l -v 'myimage.gif'
              Yup that works great V_Rocks
              AIM: PerlScriptor

              Comment

              • rivalen
                Registered User
                • Apr 2003
                • 8

                #8
                Originally posted by rivalen
                find . -name "index.html" -exec grep -qsv "myimage.gif" '{}' \; -print
                hmmm...my command got ganked...haha123; should be the opening bracket

                Comment

                • NiteRain
                  Confirmed User
                  • Jul 2002
                  • 600

                  #9
                  Originally posted by V_RocKs
                  find . -type f -name "index.html" | xargs cat|grep -l -v 'myimage.gif'
                  Get this Standard Input message on this one.
                  AIM: PerlScriptor

                  Comment

                  • V_RocKs
                    Damn Right I Kiss Ass!
                    • Nov 2003
                    • 32449

                    #10
                    Originally posted by NiteRain
                    Get this Standard Input message on this one.
                    Yeah... I didn't read the part about it outputing the files name...

                    Comment

                    Working...