Sed function is shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sed function is shell scripting
# 8  
Old 03-05-2009
Quote:
Originally Posted by kev_1234
Right this is what I entered into my Command Terminal:

Please use the correct tags.

If you are posting code, including command-line entry and output, use [code] tags.

If you are posting HTML, use [HTML] tags.

Do not use [QUOTE] for new material; nested quotes are stripped from replies.
Quote:

Code:
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.....

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

output
HTML Code:
<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.

Those are hyperlinks.
# 9  
Old 03-05-2009
Quote:
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.
# 10  
Old 03-05-2009
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?
# 11  
Old 03-05-2009
Quote:
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:

Code:
# 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
# 12  
Old 03-05-2009
Quote:
Originally Posted by kev_1234
I know, but they are not clickable!

Of course they are -- in a web browser. That's where one uses hyperlinks.
Quote:
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.

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?
# 13  
Old 03-05-2009
Quote:
Originally Posted by cfajohnson

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.......Smilie

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 explainsSmilie
# 14  
Old 03-05-2009
Quote:
Originally Posted by kev_1234
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.....

How does your text editor do that?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

New to Shell Scripting: Need help interpreting example function

In this example function below, I cannot figure out what certain parts mean. if ! echo $PATHwhat is "if !"? (^|:)$1($|:) What is ^|: and$|:? pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if ; then PATH=$PATH:$1 else... (3 Replies)
Discussion started by: MemberName
3 Replies

2. Shell Programming and Scripting

Need help to write a function in shell scripting to execute sql files

Hi, I am new to shell scripting and i need to write a automation script to execute sql files. I need to check the table if it is there in system tables and need to write a function to call the .sql files. For ex. I have a.sql,b.sql,c.sql files, where the sql file contains DELETE and INSERT... (1 Reply)
Discussion started by: Samah
1 Replies

3. Shell Programming and Scripting

Help shell scripting using awk or sed or other

I need to create a script to change a file depending of 3 conditions using a target as parameter... first condition <chamada> <numeroTerminalOriginador>CALLER</numeroTerminalOriginador> <imeiOriginador></imeiOriginador> <cgiPrimeiraErbOriginador></cgiPrimeiraErbOriginador>... (2 Replies)
Discussion started by: poulis
2 Replies

4. Shell Programming and Scripting

Mail function in shell scripting

Hi Guys, i'm new to scripting, please help me to write the script. Purpose: To write a simple addition program and to mail the output result. Script: #!/bin/bash echo "entr numbers"; read n1; read n2; answer=$(($n1+$n2)); echo $answer > mail -s "output" karthic324n@gmail.com; ... (4 Replies)
Discussion started by: Karthick N
4 Replies

5. Shell Programming and Scripting

Shell Scripting Function call return value

Hi I have a function : Make_Report() { trx_report=`sqlplus -s $conn_str << @@ set echo off; set pages 0; set feedback off; set verify off; select srv_trx_s_no,... (1 Reply)
Discussion started by: neeraj617
1 Replies

6. Shell Programming and Scripting

/usr/bin/time Shell Scripting Function

Hello, I have made a Linux Shell Script that downloads 6 files from the Internet and then deletes them. Now i want to use the function "/usr/bin/time" and "bc" to calculate how long the avergate run time for the shell script is. I therefore need to do it 100 times. My shell script code is below: ... (6 Replies)
Discussion started by: solo2
6 Replies

7. Shell Programming and Scripting

Shell Scripting -- sed

Hi, In one of my scripts, I am using sed to do an expression replacement. The code in the script is as under sed "s|MY_INP_Lab=""|MY_INP_Lab="${2}"|" file1, where $2=xyz_abc_mbk The EXPECTED output is in file1, all the instances ofMY_INP_Lab="" shall be replaced by... (2 Replies)
Discussion started by: vivekmattar
2 Replies

8. Shell Programming and Scripting

Scripting awk or sed or shell

input buff_1 abc satya_1 pvr_1 buff_2 def satya_1 pvr_1 buff_3 ghi satya_1 pvr_1 buff_4 jkl satya_1 pvr_1 required out put buff_1 abc satya_1 pvr_1 abc satya_1 buff_2 def satya_1 pvr_1 def satya_1 buff_3 ghi satya_1 pvr_1 ghi satya_1 (6 Replies)
Discussion started by: pvr_satya
6 Replies

9. Shell Programming and Scripting

Insert a function in a jsp file using Shell scripting

Greetings to all.I am new to the forum as well as to UNIX as well.I have a jsp file which has the following selectedStartMonth = request.getParameter( "startMonth" ); selectedStartDay = request.getParameter( "startDay" ); selectedStartYear = request.getParameter( "startYear" );... (3 Replies)
Discussion started by: 20033716
3 Replies

10. Shell Programming and Scripting

Help on SED AWK in shell scripting

Hi, I have a script abc.sql which contains a word 'timestamp'. I have another script xyz.txt genrated everyweek, which has a new timestamp value every week. How do I replace the word 'timestamp' in script abc.sql with the value mentioned in the script xyz.txt, so that I can run the script... (3 Replies)
Discussion started by: kaushys
3 Replies
Login or Register to Ask a Question