Sponsored Content
Full Discussion: sed matching
Top Forums Shell Programming and Scripting sed matching Post 302979045 by p1ne on Monday 8th of August 2016 08:27:06 AM
Old 08-08-2016
Thanks, both those commands hang/freeze in bash terminal, but they led to solving in 2-parts, which I'd like to consolidate into 1:
Code:
sed -n '/story-title="/s/\(.*"\)/\1/p' original > output

this extracts just the trending-story line, omitting all unnecessary HTML:
Code:
<trending-story id="US_lnk_swT_mwAwAABMLM_en" sparkline="story.sparkline" story-index="(pageIndex * ctrl.trendingStoriesPerPage) 
+ storyIndex + 1" story-title="Vaccine, Zika virus" story-title-array="story.entityNames" image-url="//t0.gstatic.com/images?q=tbn:ANd9GcRbjJz
A7QdFk9ILYGiBBRNHdH3Q_S8hwVBzsBuEeZLNG-O1LoE2inJDx0aSQl6YuU24cRzhk2Faqyg" news-url="http://www.universityherald.com/articles/
36465/20160807/zika-vaccine-university-of-maryland-works-on-zika-vaccine-and-tests-on-human.htm" image-source="University Herald" hide-image=
"ctrl.hideAllImages" show-news-snippet="false" sparkline-size="ctrl.sparklineSize" class="ng-isolate-scope"><div class="trending-story-wrapper">

and this:
Code:
sed -r 's/.*story-title="([^"]+).*/\1/' output > output2

outputs what I want:
Code:
Vaccine, Zika virus

I tried running the sed -r command above with "original" file > output, and it also freezes/hangs in terminal. Anyhow, suggestion for consolidating the 2 working scripts would be appreciated.

Last edited by p1ne; 08-08-2016 at 01:00 PM.. Reason: code lines too long
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pattern matching sed

MSG="THERE WERE XX RECORDS IN ERROR TABLE,AAAA, WHEN LOADING THE BBBB TABLE WITH EXTRACT FROM CCCC INTO TABLES FOR , DATABASE DDDD." echo "$MSG" > /tmp/mplanmsg.$$.out I wan to replace XX with the content in $recordXX cat /tmp/mplanmsg.$$.out|sed 's/XX/\$recordXX/g'| sed... (3 Replies)
Discussion started by: leemjesse
3 Replies

2. Shell Programming and Scripting

Matching '/' in SED

Hello, I have a list of filename is a file called list.dat. The filenames appear in the list.dat file as this: ./set.class ./one.class I want to delete these file names from the list file using sed. To test I was trying to match just the set.class. Eventually I want to delete all... (5 Replies)
Discussion started by: bestbuyernc
5 Replies

3. Shell Programming and Scripting

Matching everything on a line using sed

I having a little trouble. I want to substitute whatever is on the first line no matter what is on it with the word BEGINNING. So on the first line, the only word on it is BEGINNING I tried the following: sed '1,1s/^ *.*$/BEGINNING/g' $FILE It works only if the 1st line starts with a... (2 Replies)
Discussion started by: quixoticking11
2 Replies

4. Shell Programming and Scripting

matching ' in sed

Hi, I need to match some text in sed that contains the ' character. I have tried a escaped character but it doesn't work (that is, something like sed 's/\'/whatever/g') Does anyone know how to specify the ' character in the left part of sed? Thanks in advance. (2 Replies)
Discussion started by: luisrr
2 Replies

5. Shell Programming and Scripting

sed pattern matching

Hi all, if I have the following piece (repeating) of text within a file and I wish to delete it via sed a b c d e <tr> <td><img alt="" height="1" width="3" src="/testweb/view/browser/images/shim.gif"></td><td><img alt="" height="1" ... (4 Replies)
Discussion started by: srage
4 Replies

6. Shell Programming and Scripting

sed pattern matching

Unfortunately this chap has been banned for some reason and I was looking forward to the resolution of his question: - https://www.unix.com/shell-programming-scripting/123118-append-position-28-33-a.html He was asking if you can use sed to match a pattern you want to replace within a... (6 Replies)
Discussion started by: steadyonabix
6 Replies

7. Shell Programming and Scripting

SED pattern matching help

Hello All, I have the following lines in a file <address location="test" ConnectionName="test" /> I want to replace the above lines by <address location="test123" /> I am usind SED and not able to remove the new line characters between the two lines. Can anyone please help... (4 Replies)
Discussion started by: ramk
4 Replies

8. Shell Programming and Scripting

help! Pattern Matching in vi or sed

I have a bunch of conf files, that contain the fully qualified names of servers. I would like to be able to use some sort of pattern matching with sed or vi, or whatever, to pull out the fully qualified server names, and dump them in a file. It just needs to work across several unix os. So, I... (4 Replies)
Discussion started by: tabini
4 Replies

9. Shell Programming and Scripting

Help with sed pattern matching

Hi My log file is Testtmp2 cat Testtmp2 12:12:38 12:14:29 12:17:34 12:19:08 12:20:10 12:21:35 12:22:20 12:22:26 12:22:34 12:22:38 12:28:14 12:31:35 12:32:50 12:33:04 (3 Replies)
Discussion started by: rahkumar
3 Replies

10. Shell Programming and Scripting

Use sed to get first matching pattern

HI, I have a file: listenerport: - 1521 - 10520 - 10521 - 10522 - 10523 instances: listenerport: listenerport: - 1521 - 10540 - 10541 - 10542 - 10543 instances: ... (5 Replies)
Discussion started by: netbanker
5 Replies
Locale::Script(3perl)					 Perl Programmers Reference Guide				     Locale::Script(3perl)

NAME
Locale::Script - standard codes for script identification SYNOPSIS
use Locale::Script; $script = code2script('phnx'); # 'Phoenician' $code = script2code('Phoenician'); # 'Phnx' $code = script2code('Phoenician', LOCALE_CODE_NUMERIC); # 115 @codes = all_script_codes(); @scripts = all_script_names(); DESCRIPTION
The "Locale::Script" module provides access to standards codes used for identifying scripts, such as those defined in ISO 15924. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 15924 four-letter codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying scripts. The ones currently supported are: alpha This is a set of four-letter (capitalized) codes from ISO 15924 such as 'Phnx' for Phoenician. This code set is identified with the symbol "LOCALE_SCRIPT_ALPHA". The Zxxx, Zyyy, and Zzzz codes are not used. This is the default code set. numeric This is a set of three-digit numeric codes from ISO 15924 such as 115 for Phoenician. This code set is identified with the symbol "LOCALE_SCRIPT_NUMERIC". ROUTINES
code2script ( CODE [,CODESET] ) script2code ( NAME [,CODESET] ) script_code2code ( CODE ,CODESET ,CODESET2 ) all_script_codes ( [CODESET] ) all_script_names ( [CODESET] ) Locale::Script::rename_script ( CODE ,NEW_NAME [,CODESET] ) Locale::Script::add_script ( CODE ,NAME [,CODESET] ) Locale::Script::delete_script ( CODE [,CODESET] ) Locale::Script::add_script_alias ( NAME ,NEW_NAME ) Locale::Script::delete_script_alias ( NAME ) Locale::Script::rename_script_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Script::add_script_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Script::delete_script_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes man page. SEE ALSO
Locale::Codes Locale::Constants http://www.unicode.org/iso15924/ Home page for ISO 15924. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 1997-2001 Canon Research Centre Europe (CRE). Copyright (c) 2001-2010 Neil Bowers Copyright (c) 2010-2011 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-09-26 Locale::Script(3perl)
All times are GMT -4. The time now is 04:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy