SED multiple links in one line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SED multiple links in one line
# 1  
Old 11-16-2010
SED multiple links in one line

I'm using sed to pull links from a rather large html file, and so far it's working rather well, but I've noticed that it is skipping some links.

On some lines there are multiple links for example:

Quote:
Click here for LINK1 and LINK2.
It is completely skipping the first link in these.

Here is what I'm using:
Code:
sed 's/^.*<a class="slinks" href="//' | sed 's/<.*$//'

Any suggestions as to what I can do to make sure that it will work in these instances?

Thanks
# 2  
Old 11-16-2010
Why not process the file with sed first and put links on diffrent lines:

Code:
sed 's/<a class=/\n&/g' | sed 's/^.*<a class="slinks" href="//' | sed 's/<.*$//'

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 11-16-2010
how does your line look like before parsing ?
# 4  
Old 11-16-2010
Looks like that might have fixed it. I had considered about putting them on separate lines first, but thought that I would just run into the same issue.

Thanks a bunch.
# 5  
Old 11-16-2010
if you write your html file and remove the which portion then you can take more help..so what is input and desired file?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed find multiple expressions plus next next line

Hello I am trying to write sed code where it will look through the text for lines with specific expression "Started by user" and when found, will also add the following line, and also lines with another expression "Finished:" sed -n '/Started by user/, +1p, /Finished:/'... (4 Replies)
Discussion started by: dlesny
4 Replies

2. Shell Programming and Scripting

Multiple line search, replace second line, using awk or sed

All, I appreciate any help you can offer here as this is well beyond my grasp of awk/sed... I have an input file similar to: &LOG &LOG Part: "@DB/TC10000021855/--F" &LOG &LOG &LOG Part: "@DB/TC10000021852/--F" &LOG Cloning_Action: RETAIN &LOG Part: "@DB/TCCP000010713/--A" &LOG &LOG... (5 Replies)
Discussion started by: KarmaPoliceT2
5 Replies

3. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

here is what i want to achieve.. i have a file with below contents cat fileName blah blah blah . .DROP this REJECT that . --sport 7800 -j REJECT --reject-with icmp-port-unreachable --dport 7800 -j REJECT --reject-with icmp-port-unreachable . . . more blah blah blah --dport 3306... (14 Replies)
Discussion started by: vivek d r
14 Replies

4. Shell Programming and Scripting

SED - Multiple String - Single Line

Would appear to me to be a farily simple question but having search all the threads I can't find the answer .. I just want sed to output the single line in a file that contains two string anywhere on the line.. e.g. currently using this command sed -n -e'/str1/p' -e '/str2/p' < file and... (3 Replies)
Discussion started by: flopster
3 Replies

5. Shell Programming and Scripting

SED : Replace whole line on multiple execution

Hi, I am have one file with a line group=project_live I need to replace it with line group=project_live_support before I execute some application related script. The potentianl problem is when I replace this with sed using command sed... (2 Replies)
Discussion started by: bhaskar_m
2 Replies

6. Shell Programming and Scripting

sed multiple line trouble

Hello, im writing a script that validates a URL (the parameter) using http://validator.w3.org first it downloads the site (the output line I want is stored in the h2 field of the site's html. wget http://validator.w3.org/check?url=$1 2> /dev/null sed -n '/<h2/p' check?uri=$1 | sed 's/... (5 Replies)
Discussion started by: drareeg
5 Replies

7. Shell Programming and Scripting

sed replace multiple occurrences on the same line, but not all

Hi there! I am really enjoying working with sed. I am trying to come up with a sed command to replace some occurrences (not all) in the same line, for instance: I have a command which the output will be: 200.300.400.5 0A 0B 0C 01 02 03 being that the last 6 strings are actually one... (7 Replies)
Discussion started by: ppucci
7 Replies

8. Shell Programming and Scripting

Multiple line deletions with sed ???

Hi, I'm trying to delete multiple lines following a line that matches a pattern. The pattern will appear several times in a file. So when i encounter that pattern in a line, i have to delete that line plus the next 4 lines. Something similar to what grep does grep -A5 'pattern' filename.... (1 Reply)
Discussion started by: drkm_4_frm
1 Replies

9. Shell Programming and Scripting

single line input to multiple line output with sed

hey gents, I'm working on something that will use snmpwalk to query the devices on my network and retreive the device name, device IP, device model and device serial. I'm using Nmap for the enumeration and sed to clean up the results for use by snmpwalk. Once i get all the data organized I'm... (8 Replies)
Discussion started by: mitch
8 Replies

10. Shell Programming and Scripting

Multiple line match using sed

Please help! Input pattern, where ... could be any number of lines struct A { Blah1 Blah2 Blah3 ... } B; output pattern struct AB { Blah1 Blah2 Blah3 ... }; I need help in extracting everything between { and } if it would have been on a single line { \(.*\)} should have worked. (15 Replies)
Discussion started by: SiftinDotCom
15 Replies
Login or Register to Ask a Question