Linux/Unix gurus...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EddiePulp
    Confirmed User
    • Mar 2004
    • 1332

    #1

    Linux/Unix gurus...

    Yo,
    Just wanting to know what command I could use to go through all sub directories and search THROUGH html files and replace </html> with <a href=.....</a></html>
    I dont need a sig.
  • darnoth
    Confirmed User
    • Jan 2005
    • 105

    #2
    perl -pi -e '\s/old/new/' filemask .. so:
    perl -pi -e '\s/<\/html>/<a href=http:\/\/www.yahoo.com\/search/' *
    That only does the current directory, but you can do */*, then */*/* etc. You'll notice I put \'s in front of the /'s, thats because those are special characters, and you need to "escape" them by putting those there. You should put \'s in front of " characters as well if you use them in the href. I suggest creating a test file and testing it on that until you get it right .

    Comment

    • EddiePulp
      Confirmed User
      • Mar 2004
      • 1332

      #3
      thanks a bunch darnoth!
      I dont need a sig.

      Comment

      • INDK
        Confirmed User
        • Jan 2004
        • 75

        #4
        Not quite darnoth.

        USE AT YOUR OWN RISK

        First, make a backup of that directory. Then edit the obviously phony (capitalized) variables in this command to your liking:

        Code:
        find /PATH/TO/DIRECTORY/GOES/HERE/ -type f -name "*.html" | while read f; do perl -pe 's,\</html\>,<a href="LINKGOESHERE">HYPERTEXT</a></html>,' "$f" > "$f".new; mv "$f".new "$f"; done
        ...will recursively scan through /www/directory/goes/here and replace </html> with <a href="LINKGOESHERE">HYPERTEXT</A> in every single HTML file in that directory. Don't run this more than once.

        Comment

        • EddiePulp
          Confirmed User
          • Mar 2004
          • 1332

          #5
          INDK cheerS!
          I dont need a sig.

          Comment

          • EddiePulp
            Confirmed User
            • Mar 2004
            • 1332

            #6
            hmm neither seemed to work

            the idea is to put in .sh file and run, right?
            I dont need a sig.

            Comment

            • INDK
              Confirmed User
              • Jan 2004
              • 75

              #7
              No, just run it.

              Describe the error.

              Comment

              • EddiePulp
                Confirmed User
                • Mar 2004
                • 1332

                #8
                it seems to run.. no errors..but no resumes
                does it matter if the </HTML> is </HTML> or </html> ?
                and do I have to put \ in front of the " and <, >'s
                I dont need a sig.

                Comment

                • EddiePulp
                  Confirmed User
                  • Mar 2004
                  • 1332

                  #9
                  ahh.. it seems to work now.. thx a heaps INDK!
                  I dont need a sig.

                  Comment

                  • EddiePulp
                    Confirmed User
                    • Mar 2004
                    • 1332

                    #10
                    INDK, thanks again.. if you could, hit me up on icq 7278746

                    cheers
                    I dont need a sig.

                    Comment

                    Working...