11-22-2008
Extract a substring.
I have a shell script that uses wget to grab a bunch of html from a url.
URL_DATA=`wget -qO - "$URL1"`
I now have a string $URL_DATA that I need to pull a substring out of..say I had the following in my string
<p><a href="/scooby/929011567.html">Dog pictures check them out! -</a><font size="-1"> (Silly)</font></p> <p><a href="/shaggey/928861647.html">Vacation -</a><font size="-1"> (boating)</font></p> <p><a href="/gopher/928782568.html">Garden -</a><font size="-1"> (winter)</font></p>
I want to extract the URL, Title and Description throughout the string...like the following
/scooby/929011567.html
Dog pictures check them out!
(silly)
/shaggey/928861647.html
Vacation
(boating)
/gopher/928782568.html
Garden
(winter)
and keep going with that pattern as many times as it's in the string. How would I do this?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
On OS 10.4.11
I have filenames like:
670711 SA T2 v1-1_DS_EF.doc
CT_670520 AM T1 v1-2_DS_EF.doc
CT_670716 - 2 SA T4 v1-2_DS_EF.doc
CT_670713 SA T3 v1-1_DS_EF.doc
670421 PA DYP1 v1-1_DS_EF.doc
CT_670425 PA DYP2 v1-1_DS_EF.doc
CT_670107 RA T3 v1-2_DS_EF.doc
CT_670521 AM T2 v1-2_DS_EF.doc... (3 Replies)
Discussion started by: mlommel
3 Replies
2. Shell Programming and Scripting
> tnsping $TWO_TASK | grep HOST
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.12.10.212)(PORT = 1540)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = OMTST15)))
I want to extract like this
HOST = 10.12.10.212
PORT = 1540
SERVICE_NAME = OMTST15
I... (4 Replies)
Discussion started by: dashok.83
4 Replies
3. Solaris
i have srtring i.e. "NAME,CLASS,AGE" (length of string is not constant) and from this string i've extract each word delimited by "," (comma).
INPUT: "NAME,CLASS,AGE"
OUTPUT: NAME
CLASS
AGE
how can i do that?
i have tried some string manipulation function like... (5 Replies)
Discussion started by: jadoo_c2
5 Replies
4. Shell Programming and Scripting
Hi,
I'm a newbie to shell scripting and have searched the forum but couldn't find what i was looking for.
Basically I have a list of filenames like...
123-fileone.txt
I want to be able to extract the prefix up to the first '-'. So I'd end up with 123. I have attempted it using a pretty... (2 Replies)
Discussion started by: kirkg
2 Replies
5. Shell Programming and Scripting
Hi,
I have an input string say for example:
ABC,DEF,IJK,LMN,...,XYZ
The above string is comma delimited. Now I have to extract the last part after the comma i.e. XYZ.
:b: (3 Replies)
Discussion started by: bghosh
3 Replies
6. Shell Programming and Scripting
Hi All,
I have a log file in which name and version of applications are coming in the following format
name
It may look like following, based on the name of the application and version:
XYZ OR xyz OR XyZ OR xyz
I want to separate out the name and version and store them into variables.... (4 Replies)
Discussion started by: bhaskar_m
4 Replies
7. Shell Programming and Scripting
Hi
Input:
aa-bb-cc-dd.ee.ff.gg
Output:
dd
I want to get the word after the last '-' until the first dot
I have tried with regex lookbehind and lookahead like this:
(?<=-).*(?=\.)
but his returns too much
bb-cc-dd.ee.ff (7 Replies)
Discussion started by: chitech
7 Replies
8. Shell Programming and Scripting
Hello,
A question please.
A have a file that contains a string. Ex:
AAAABBCCCCCDDEEEEEEEEEEFF
I'd want to recover 2 substrings, 'BB' and 'FF' and then leave them in a new file.
Could anoyone help me please?
Thanks in advance (3 Replies)
Discussion started by: nolo41
3 Replies
9. Shell Programming and Scripting
Hello,
A question please.
A have a file that contains a string. Ex:
AAAABBCCCCCDDEEEEEEEEEEFF
I'd want to recover 2 substrings, 'BB' and 'FF' and then leave them in a new file.
From position 5, 2 caracters (ex:"BB") and from position 25, 2 caracters (ex:"FF") in a file.
Could anoyone help me... (3 Replies)
Discussion started by: nolo41
3 Replies
10. Shell Programming and Scripting
Hi all,
Please, i'd like to extract string just before '.fr'.
Here is some lines of my file:
g-82.text.text1.fr.worker1
g-xx.yyyyyy.zzzz.fr.worker2
i'd like to extract this text:
g-82.text.text1
g-xx.yyyyyy.zzzz
Please, which command i have to use in my script shell ?
... (16 Replies)
Discussion started by: chercheur111
16 Replies
LEARN ABOUT DEBIAN
platform::shell
platform::shell(3tcl) Tcl Bundled Packages platform::shell(3tcl)
__________________________________________________________________________________________________________________________________________________
NAME
platform::shell - System identification support code and utilities
SYNOPSIS
package require platform::shell ?1.1.4?
platform::shell::generic shell
platform::shell::identify shell
platform::shell::platform shell
_________________________________________________________________
DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell.
This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only
requirement is that the other shell (identified by its path), is actually executable on the current machine.
While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell
this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run
32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers.
For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed
packages, versus the architecture of the shell running the repository software.
COMMANDS
platform::shell::identify shell
This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell.
platform::shell::generic shell
This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell.
platform::shell::platform shell
This command returns the contents of tcl_platform(platform) for the specified Tcl shell.
KEYWORDS
operating system, cpu architecture, platform, architecture
platform::shell 1.1.4 platform::shell(3tcl)