Sed function is shell scripting

Hello everybody,

I trying to convert a text inside my file that looks something like this:

into hyperlink so that the user can click onto it.....
I tried this but doesn't work

cat mylist9.html |sed -e '<a href="' >mylist13.html

Thanks

Are there really all those quotes around the URL?

What does "doesn't work" mean? What does happen? How does that differ from what you want to happen?

Do you get any error messages? If you did, did you read them? They would at least give you a clue what is wrong. If reading them doesn't help, them post them!!

There's no need for cat:

sed -e '<a href="' mylist9.html >mylist13.html

But that is not a valid sed command.

No those quotes were to stop the forum converting it to into this

Volkswagen Polo (new) | Driver Power 2007 | Car Reviews | Auto Express

Any ways,
when i say it doesn't work is that it is not converted in to hyperlink.......
still remains as a **http://blah.com**.....without any errors.....

what about something like?

awk '{print "<a href="$0">"}' inputfile >outputfile

Without understanding your actual text file, and what you want the output file to be, this is just a guess.

Thanks for the code....yes it converts it into

But I would like the user be able to 'click' on it which opens the webpage

Then use the correct tags,

:



http://www.autoexpress.co.uk/carreviews/driver_power_2007/207826/volkswagen_polo_new.html

Any ways,
when i say it doesn't work is that it is not converted in to hyperlink.......
still remains as a **http://blah.com**.....without any errors.....
[/quote]

[indent]
Then you didn't post the actual command you used; that command would have given you errors.

I think this should do what you want:

awk '{ printf "<a href=\"%s\">%s</a>\n", $0, $0 }' file > newfile

Right this is what I entered into my Command Terminal:

which goes through 'wget' looks up and google and posts the results into the file mylist1.html.......after this it goes through all the 'sed' function to remove unwanted items.....

awk '{ printf "<a href=\"%s\">%s</a>\n", $0, $0 }' mylist9.html >mylist13.html

output

I want them to be HYPERLINK so the user is directed towards the webpage.

Thanks

Please use the correct tags.

If you are posting code, including command-line entry and output, use

 tags.

If you are posting HTML, use  tags.

Do not use  for new material; nested quotes are stripped from replies.




kevin@ubuntu:~/Documents/test$./goog -s VW 

which goes through 'wget' looks up and google and posts the results into the file mylist1.html.......after this it goes through all the 'sed' function to remove unwanted items.....

awk '{ printf "<a href=\"%s\">%s</a>\n", $0, $0 }' mylist9.html >mylist13.html

output

<a href="http://uk.youtube.com/results?q=vw&um=1&ie=UTF-8&sa=N&hl=en&tab=w1">http://uk.youtube.com/results?q=vw&um=1&ie=UTF-8&sa=N&hl=en&tab=w1</a>
<a href="http://www.volkswagen.co.uk/">http://www.volkswagen.co.uk/</a>
<a href="http://www.volkswagen.co.uk/used">http://www.volkswagen.co.uk/used</a>
<a href="http://www.volkswagen-vans.co.uk/">http://www.volkswagen-vans.co.uk/</a> 

I want them to be HYPERLINK so the user is directed towards the webpage.
[/quote]

[indent]
Those are hyperlinks.

I know, but they are not clickable!

Apologies if I framed the question wrongly.......
I want to be able to click on those hyperlinks so that It opens a web browser which will take me to that website.

The syntax as you posted it should produce clickable hyperlinks. Could you attach some of your non-working output so we can help find what went wrong?

Sorry I am not sure what you mean by non-working output....but here is half of my script:

# This passes the request from the inputted searchphrase by the user, to go and lookup the google search engine and post the result in the output file mylist.html
wget  -t1  -E -e robots=off -awGet.log -T 200 -H -Priserless -O mylist1.html -U "Mozilla" "http://www.google.co.uk/search?q=${searchphrase}&btnG=Search"
# put a newline at the start of a link
cat mylist1.html |sed -e 's#<a href#\n<a href#g' >mylist2.html
# put a newline at the end of link 
cat mylist2.html |sed -e 's#</a>#</a>\n#g' >mylist3.html
# now we need to extract all lines that begin with <a href="http:
cat mylist3.html |sed -n -e '/^<a href="http:/p' >mylist4.html
# now remove urls that contain google
cat mylist4.html |sed -n -e '/\.google/!p' >mylist5.html
# now remove urls that are numeric
cat mylist5.html |sed -n -e '/[0-9]*[0-9]*[0-9]*\.[0-9]*[0-9]*[0-9]*\.[0-9]*[0-9]*[0-9]*\.[0-9]*[0-9]*[0-9]*/!p' >mylist6.html
# Remove all HTML tags 
cat mylist6.html |sed -e :a -e 's/<[^>]*>//g;'  >mylist7.html
# Delete <a href=" before every text line
cat mylist6.html |sed -e 's#<a href="#\n#' >mylist8.html
# Delete everything after '"', and get rid of blankspace
cat mylist8.html |sed -e 's#"#\n"#' |sed -n -e '/"/!p' |sed -e '/./!d' >mylist9.html
# Remove 'http://' before every text, and get rid of blankspace
cat mylist9.html |sed -e 's#http://#\n#' |sed -e '/./!d' >mylist10.html
# Remove textline after '/' from the file
cat mylist10.html |sed -e 's#/#\n/#' |sed -n -e '/^\//!p' |sed -e '/./!d' >mylist11.html
# Join texts from file13 with file10
sdiff mylist11.html mylist9.html >mylist12.html
# clickable hyperlink
awk '{ printf "<a href=\"%s\">%s</a>\n", $0, $0 }' mylist9.html >mylist13.html

Thanks

Of course they are -- in a web browser. That's where one uses hyperlinks.

In what program do you want to be able to do that? Whatever it is, it is up to that program to allow it or not. Does that program need a different format? If so, what?

OK! OK! alot of confusion.......Sorry I am sick today so have to explain alot.......:rolleyes:

Yes the code works in a web browser......

But I want to be able to click on the hyperlink in the text-editor where I open the mylist13.html file! Once clicked on this hyperlink it opens a browser and go to the websiter.....

Hope this explains:)

How does your text editor do that?