print variable length text from the middle of a line?
I am trying to get text from a webpage, in terminal form. So far I am:
1. getting the html for the page printed using curl (curl -s webpage.com), which is then
2. piped to awk, printing line number 29 (awk NR==29), then
3. this is where I am sort of lost. I know where in the printed line I want to start (character 686), but the text I want to print can vary quite a bit in length.
Here is part of the output:
<span style="font-size:14px; color:#347C17">THIS IS THE SECTION I WANT PRINTED</span>
In that example, starting at character 686 (of the full output) would be the capital T. And like I said, that "section" before the </span> can be different lengths.
I believe it is the only set of <span> tags on the line, if that helps at all.
[edit] got it to work, but it looks pretty terrible
What version of awk are you running, and under which O/S? If you are on a Solaris box you might want to use nawk or /usr/xpg4/bin/awk (I think that's the path -- I don't have a sun box at hand to check this morning).
What version of awk are you running, and under which O/S? If you are on a Solaris box you might want to use nawk or /usr/xpg4/bin/awk (I think that's the path -- I don't have a sun box at hand to check this morning).
My sample file is variable length, with out any field delimiters. It has min of 18 chars length and the 'CRLF' is potentially between 12-14 chars. How do I replace this with a space? I still want to keep end of record, but just want to remove these new lines chars in the middle of the data.
... (7 Replies)
Hello,
I am looking for a specific situation in a text file. The conditions are,
> <CompoundName>
InChI=1S/C5H12NO2/c1-5(2)4-8-6(3)7/h5H,4H2,1-3H3/q+1
I am looking for cases where the line "> <CompoundName>" is followed by a line that contains the string "InChI=" without regard to... (5 Replies)
I have several questions about using awk. I'm hoping someone could lend me a hand. (I'm also hoping that my questions make sense.)
I have a file that contains pipe separated data. Each line has similar data but the number of fields and the field position on each line is variable. ... (3 Replies)
Hi,
Can anyone help with a effective solution ?
I need to change a variable length text field (between 1 - 18 characters) to a fixed length text of 18 characters with the unused portion, at the end, filled with spaces.
The text field is actually field 10 of a .csv file however I could cut... (7 Replies)
Hi Unix experts
I have simple text files in which the number of lines vary from one file to another. They look like the following:
#
#
.
.
34 46
76 72
39 68
I want to grab the first number of the last line of each file (let's say A= 39 in the above example), which is... (2 Replies)
Hi,
Please let me know how to find text and print text and its previous line. Please don't get irritated few days back I asked text and next line. I am using HP-UX 11.11
Thanks for your help. (6 Replies)
how to print any required line by its line no using awk and its NR variable
for eg:
------------
121343
adfdafd
21213sds
dafadfe432
adf.adf%adf
---------------
requied o/p if give num=3 it print:
21213sds
-------------------------------------- (2 Replies)
I've got a configuration file that is filled with xml text statements for example:
<...../>
<...../>
<...../>
<data id="java-options" value="-server -Djava.security.policy..../>
<...../>
<...../>
<...../>
I want to write a korn shell script that will go to this specific line and add a... (2 Replies)
Script 1
Pre-requisites
Create a file with x amount of lines in it, the content of your choice.
Write a script that takes two arguments. The first being a line of text, the second being your newly created file. The script should take the first argument and insert it into the very top (the... (3 Replies)
Is there a command that sets a variable length?
I have a input of a variable length field but my output for that field needs to be set to 32 char.
Is there such a command?
I am on a sun box running ksh
Thanks (2 Replies)