printing lines contain double quote


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting printing lines contain double quote
# 1  
Old 07-05-2010
printing lines contain double quote

Hello ,
I got html file , these file are normal html as we can see .

what i would like to do is in this html file , i want to print only string start with double quote and end with double quote by line by line.

Code:
<tr><td valign=top>25.</td><td><A href="../XMLL/CatalogL.htm">XML</a></td></tr>
<tr><td valign=top>26.</td><td><A href="../XMLNQ/CatogXML-LINQ.htm">

the out put should look like
"../XMLL/CatalogL.htm"
"../XMLNQ/CatogXML-LINQ.htm"


is that simple or a lot work to do or can anybody share code.


Many thanks
# 2  
Old 07-05-2010
Code:
nawk -F'"' '{for(i=2;i<=NF;i+=2) print FS $i FS}' myFile.html

# 3  
Old 07-05-2010
In perl:
Code:
perl -ne '/".+"/; print $& . "\n"' file

Shorter perl:
Code:
perl -nle 'print /".+"/g' file


Last edited by bartus11; 07-05-2010 at 01:08 PM..
# 4  
Old 07-05-2010
Using sed
Code:
sed -n 's/^.*href=\(".[^"]*"\).*$/\1/p' file

# 5  
Old 07-05-2010
Another sed:
Code:
sed 's/.*=//;s/>.*//' file

# 6  
Old 07-05-2010
awk 'BEGIN {FS="\""} {print "\""$2"\""}' myFile
# 7  
Old 07-05-2010
Many thanks for all reply , it work great, but want to ask a question , if i want to modify

if string startwith <div class="codedom"> and endwith <code> , i mean

stringstart = <div class="codedom">
stringend = <code>

i want to print whole thing like

Code:
<div class="codedom"> ......................................
......................................................................
.......................................................................
......................................................................
.......................................................................
......................................................................
.............................................................<code>

how do i modify this because i don't see any start and end from above code


thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies

2. Shell Programming and Scripting

Replacing Double Quote in Double Quote incsv file

Hi All , We have source data file as csv file and since data could contain commas ,each attribute is quoted into double quotes.However problem is that some of the attributa data also contain double quotes which is converted to double double quote while creating csv file XLs data : ... (2 Replies)
Discussion started by: Shalini Badal
2 Replies

3. Shell Programming and Scripting

Replace double quotes with a single quote within a double quoted string

Hi Froum. I have tried in vain to find a solution for this problem - I'm trying to replace any double quotes within a quoted string with a single quote, leaving everything else as is. I have the following data: Before: ... (32 Replies)
Discussion started by: pchang
32 Replies

4. Shell Programming and Scripting

Double quote filenames

Hi, I need to double quotes filenames in the following string: /tmp/*file1 /tmp/*file2 /tmp/*file3 /tmp/*file4I tried to do this using sed, but it double quotes every character :wall: $ echo... (10 Replies)
Discussion started by: Subbeh
10 Replies

5. Shell Programming and Scripting

getting value between double quote

Can somebody supply me with a simple way to get a value between two double quotes? Example: input = ADR base is "/u01/app/oracle" output = /u01/app/oracle Thanks to all who answer (4 Replies)
Discussion started by: BeefStu
4 Replies

6. Shell Programming and Scripting

double quote as the delimiter

I'm trying to extract a column from a csv file with either cut or awk but some of the fields contain comma with them: "Field1","Field2, additional info","Field3",...,"Field17",... If I want to extract column 3 and use comma as the delimiter, I'll actually get the additional info bit but not... (4 Replies)
Discussion started by: ivpz
4 Replies

7. Shell Programming and Scripting

replacing a quote in some lines with multiple quote fields

i want to replace mistaken quotes in line starting with tag 300 and relocate the quote in the correct position so the input is 223;25 224;20100428064823;1;0;0;0;0;0;0;0;8;1;3;9697;18744;;;;;;;;;;;; 300;X;Event:... (3 Replies)
Discussion started by: wradwan
3 Replies

8. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

9. Shell Programming and Scripting

double-quote inside double-quote

hey all, i made a simple .sh like this: echo "<style media="screen" type="text/css">@import url("main.css");</style>" but the output is: <style media=screen type=text/css>@import url(main.css);</style> i want to keep double-quotes, can anyone help me? thanks (3 Replies)
Discussion started by: indraf
3 Replies
Login or Register to Ask a Question