the unix command sed

Forums › Forums › General Discussions › Open Topic › the unix command sed

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #45728
    bob
    Participant

      Hey,
      trying to write a script that will take a html file and removing everything but the local links.

      menu.html
      faq.html
      stuff/morestuff.html

      etc.

      I think the sed command is what I want but maybe there’s a better way

      I tried sed – e ‘/"//g’ index.html

      and this removed all of the double quotes but I can’t make it remove all of the single quotes

      I guess how I think the program should work is to remove all double and single quotes then remove all lines that don’t include <a and href then remove everything that’s not between href= and > after that removing everything after .html

      anyone think of a better command, algorithm, how to do the single quote thing, or how to do something that will replace everything BUT

      #91220
      Mattman
      Participant

        Hmm, I don’t know that I fully understand what you’re trying to do, but I’ve noticed in several programming/scripting languages that if you need it to recognize a single quote, then use ‘ or ” (two single quotes together.)

        Might work… Good luck. :D

        #91221
        bob
        Participant

          yeah, I was in c shell and that’s why it did that, I did the thing now and it solved it.
          Now I have to figure out how to run sed on shell variables

          #91222
          nickburnz
          Participant

            man sed

            :P

            #91223
            bob
            Participant

              here’s how I figured it out
              with sed you don’t have to use / as delims for substittute you can use anything – for example

              as for how to set a variable to the results of a command put

              var1=`command`

              need to use the ` things

            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.