Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Extract content between strings Post 303038629 by MadeInGermany on Monday 9th of September 2019 03:32:53 AM
Old 09-09-2019
Two substitutions is best here.
You can do it with one substitution though, as you intended.
Code:
sed 's/.*"title": "\([^"]*\)",.*/\1/'

Leading and trailing. * cover all the line, so all is substituted.
The .* is greedy; use [^"]* to ensure the following ", is the first one, in case there are more ", following.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help to extract the content in this string

Hi All, I have a string in the following format: "kf skjgsdjgngnsd sdgsd ksjgbksjgb kjsbgsjdgb dfhdh sjgsjg j jsbekgjsbdkgj". In this format i want to extract the contents which is in between the two empty lines:... (6 Replies)
Discussion started by: bala041
6 Replies

2. Shell Programming and Scripting

How extract strings (perl)

Sample data: revision001 | some text | some text Comment: some comment Brief: 1) brief 2) brief ------------------------------------------ revision002 | some text | some text Brief: 1) brief 2) brief FIX: some fix ------------------------------------------ revision003 | some... (8 Replies)
Discussion started by: inotech
8 Replies

3. Shell Programming and Scripting

How can i delete the content between all the occurences of two strings using sed or awk command

Hi. I have to delete the content between all the occurrences of the xml tags in a single file. For example: * The tags <script>.....................</script> occurs more than once in the same file. * It follows tagging rules meaning a start tag will be followed by an end tag. Will not have... (9 Replies)
Discussion started by: satheeshkumar
9 Replies

4. Shell Programming and Scripting

Extract Content from a file

I have an input file with contents like: ./prbru6/12030613.LOG:24514|APPL|prbru6.8269.RTUDaemon.1|?|13:49:56|12/03/06|GMT+3|?|RTUServer Error:Count of Internal Error Qty (-1) < 0, for Audit group id - 1L5XVJ6DQE36AXL, after record number,1, File: EventAuditor.cc, Line: 394|? ... (5 Replies)
Discussion started by: rkrish
5 Replies

5. Shell Programming and Scripting

Extract two strings from a file and create a new file with these strings

I have the following lines in a log file. It would be great if some one can help me to create a new file with the just entries in the below format. 66.150.161.195 HPSAC=Z05 66.150.161.196 HPSAC=A05 That is just extract the IP address and the string DPSAC=its value 66.150.161.195 -... (1 Reply)
Discussion started by: Tuxidow
1 Replies

6. Shell Programming and Scripting

sed to extract all strings

Hi, I have a text file containing 2 lines as follows: I'm trying to extract all the strings following an "AME." The output would be as follows: BUSINESS_UNIT PROJECT_ID ACTIVITY_ID RES_USER1 RESOURCE_ID_FROM ANALYSIS_TYPE BI_DISTRIB_STATUS BUSINESS_UNIT PROJECT_ID ACTIVITY_ID... (5 Replies)
Discussion started by: simpletech369
5 Replies

7. UNIX for Dummies Questions & Answers

Extract code between 2 strings.

Hi, Im having some problems with this. I have loaded a file with html code. All code is placed in the same line. I want to get everything between two given strings (including these strings and get only the first appearance). Example: File contains <html><body><a href='a.html'>abc</a><a... (5 Replies)
Discussion started by: ngb
5 Replies

8. UNIX for Dummies Questions & Answers

Extract strings based on the value

I have a file with multiple columns (in this case, the file has 3 columns): NM_001006304 (-33.7) XM_418228 (-38.4) JN880447 (-33.7) CR387600 (-33.7) CR524203 (-36.3) GALGA_6AKII_KRT75 (-33.7) GALGA25_SC7 (-31.9) CR352795 (-36.3) NM_204172 (-31.7) NM_204137 (-31.9) NM_001030561 (-36.3) AB011672... (7 Replies)
Discussion started by: yuejian
7 Replies

9. UNIX for Dummies Questions & Answers

Issue when using egrep to extract strings (too many strings)

Dear all, I have a data like below (n of rows=400,000) and I want to extract the rows with certain strings. I use code below. It works if there is not too many strings for example n of strings <5000. while I have 90,000 strings to extract. If I use the egrep code below, I will get error: ... (3 Replies)
Discussion started by: forevertl
3 Replies

10. Shell Programming and Scripting

Extract strings from output

I am having the following output when executing a dig command : dig @1.1.1.1 google.com +noall +answer +stats ; <<>> DiG 9.11.4-P1 <<>> @1.1.1.1 google.com +noall +answer +stats ; (1 server found) ;; global options: +cmd obodrm.prod.at.dmdsdp.com. 86154 IN A ... (1 Reply)
Discussion started by: liviusbr
1 Replies
Mojo::Content(3pm)					User Contributed Perl Documentation					Mojo::Content(3pm)

NAME
Mojo::Content - HTTP 1.1 content base class SYNOPSIS
use Mojo::Base 'Mojo::Content'; DESCRIPTION
Mojo::Content is an abstract base class for HTTP 1.1 content as described in RFC 2616. EVENTS
Mojo::Content can emit the following events. "drain" $content->on(drain => sub { my ($content, $offset) = @_; ... }); Emitted once all data has been written. $content->on(drain => sub { my $content = shift; $content->write_chunk(time); }); "body" $content->on(body => sub { my $content = shift; ... }); Emitted once all headers have been parsed and the body starts. $content->on(body => sub { my $content = shift; $content->auto_upgrade(0) if $content->headers->header('X-No-MultiPart'); }); "read" $content->on(read => sub { my ($content, $chunk) = @_; ... }); Emitted when a new chunk of content arrives. $content->unsubscribe('read'); $content->on(read => sub { my ($content, $chunk) = @_; say "Streaming: $chunk"; }); ATTRIBUTES
Mojo::Content implements the following attributes. "auto_relax" my $relax = $content->auto_relax; $content = $content->auto_relax(1); Try to detect broken web servers and turn on relaxed parsing automatically. "headers" my $headers = $content->headers; $content = $content->headers(Mojo::Headers->new); Content headers, defaults to a Mojo::Headers object. "max_leftover_size" my $size = $content->max_leftover_size; $content = $content->max_leftover_size(1024); Maximum size in bytes of buffer for pipelined HTTP requests, defaults to the value of the "MOJO_MAX_LEFTOVER_SIZE" environment variable or 262144. "relaxed" my $relaxed = $content->relaxed; $content = $content->relaxed(1); Activate relaxed parsing for HTTP 0.9 and responses that are terminated with a connection close. METHODS
Mojo::Content inherits all methods from Mojo::EventEmitter and implements the following new ones. "body_contains" my $success = $content->body_contains('foo bar baz'); Check if content contains a specific string. Meant to be overloaded in a subclass. "body_size" my $size = $content->body_size; Content size in bytes. Meant to be overloaded in a subclass. "boundary" my $boundary = $content->boundary; Extract multipart boundary from "Content-Type" header. "build_body" my $string = $content->build_body; Render whole body. "build_headers" my $string = $content->build_headers; Render all headers. "charset" my $charset = $content->charset; Extract charset from "Content-Type" header. "clone" my $clone = $content->clone; Clone content if possible, otherwise return "undef". "generate_body_chunk" my $chunk = $content->generate_body_chunk(0); Generate dynamic content. "get_body_chunk" my $chunk = $content->get_body_chunk(0); Get a chunk of content starting from a specfic position. Meant to be overloaded in a subclass. "get_header_chunk" my $chunk = $content->get_header_chunk(13); Get a chunk of the headers starting from a specfic position. "has_leftovers" my $success = $content->has_leftovers; Check if there are leftovers. "header_size" my $size = $content->header_size; Size of headers in bytes. "is_chunked" my $success = $content->is_chunked; Check if content is chunked. "is_dynamic" my $success = $content->is_dynamic; Check if content will be dynamically generated, which prevents "clone" from working. "is_finished" my $success = $content->is_finished; Check if parser is finished. "is_multipart" my $false = $content->is_multipart; False. "is_parsing_body" my $success = $content->is_parsing_body; Check if body parsing started yet. "leftovers" my $bytes = $content->leftovers; Get leftover data from content parser. "parse" $content = $content->parse("Content-Length: 12 Hello World!"); Parse content chunk. "parse_body" $content = $content->parse_body("Hi!"); Parse body chunk. "parse_body_once" $content = $content->parse_body_once("Hi!"); Parse body chunk once. "parse_until_body" $content = $content->parse_until_body("Content-Length: 12 Hello World!"); Parse chunk and stop after headers. "progress" my $size = $content->progress; Size of content already received from message in bytes. "write" $content->write('Hello!'); $content->write('Hello!', sub {...}); Write dynamic content non-blocking, the optional drain callback will be invoked once all data has been written. "write_chunk" $content->write_chunk('Hello!'); $content->write_chunk('Hello!', sub {...}); Write dynamic content non-blocking with "chunked" transfer encoding, the optional drain callback will be invoked once all data has been written. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Content(3pm)
All times are GMT -4. The time now is 11:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy