sed multiple line trouble


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed multiple line trouble
# 1  
Old 11-02-2010
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.
Code:
 
wget http://validator.w3.org/check?url=$1 2> /dev/null
sed -n '/<h2/p' check?uri=$1 | sed 's/ *<[^>]*>//g'
rm check\?uri\=$1

but i fear that, if the h2 field would be longer than one line, the sed command wouldn't find it.
is there any option with sed (or something else) so that it doesnt like line by line?
thx in advance!


This is another version i tried, but i also fear it wouldn't work if the h2 field is longer than 1 line
Code:
wget fttp://validator.w3.org/check?url=$1 2> /dev/null
sed -n '1,$s/.*<h2[^>]*>\(.*\)<\/h2>/\1/p'  check?uri=$1
rm check\?uri\=$1


Last edited by drareeg; 11-02-2010 at 12:33 PM..
# 2  
Old 11-02-2010
Could you please post a sample of input file and expected output ?
# 3  
Old 11-02-2010


input: ./validate_html www.google.com
would give:
Errors found while checking this document as HTML5!

---------- Post updated at 11:08 AM ---------- Previous update was at 10:32 AM ----------

For example, this command works if the <h2 and </h2> aren't on the same line, but when they are on the same line, it outputs everything starting from the line untill the end .. Smilie
sed -n '/<h2/,/<\/h2>/p' check?uri=$1 | sed 's/ *<[^>]*>//g'
# 4  
Old 11-02-2010
After a quick look on Unixdaemon: Internet Explorer Plugins it seems that this plugin should be invoked through a gui interface (mouse right click)
# 5  
Old 11-02-2010
huh??
# 6  
Old 11-03-2010
Code:
wget -O - http://validator.w3.org/check?url=$1 2> /dev/null |
 sed '/<h2/!d
:y
/<\/h2>/{
s/ *<[^>]*>//g
s/\n/ /g
q
}
N
by
'


Last edited by binlib; 11-03-2010 at 09:38 PM.. Reason: Added code tag
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 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: It is completely skipping the first link in these. Here is what I'm using: sed 's/^.*<a... (4 Replies)
Discussion started by: DrMachin
4 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