Sponsored Content
Top Forums Shell Programming and Scripting How to extract a string from a file ignoring new line Post 302340592 by suresh_kb211 on Tuesday 4th of August 2009 03:43:51 AM
Old 08-04-2009
How to extract a string from a file ignoring new line

Hi,
sumdays before i had posted a query with same subject.
i got sum great help from great ppl which solved my problem then.
But now there is a small problem with the code that i need the experts help upon.

for parsing a text
Quote:
{:1:abcd :2: me myself
im}{ alone
shell}
$
{scripting: hi
how are you}{hope
ur fine}
$
{im: great}
like this
Quote:
{:1:abcd :2: me myself im}{ aloneshell}
{scripting: hihow are you}{hopeur fine}
{im: great}
where $ had been the delimiter between messages.

i have used the following piece of code
Code:
 
tr "\n" " " < file | tr "$" "\n" > output

Now there is a problem that this $ delimiter also occurs as a part of text like this
Quote:
{:1:abcd :2: me $myself
im}{ alone
shell}
$
{scripting: hi
ho$w are you}{hope
ur fine}
$
{im: great}
as a result i am getting the output like this
Quote:
{:1:abcd :2: me
myself im}{ aloneshell}
{scripting: hiho
w are you}{hopeur fine}
{im: great}
i want the parsed message to be in the format mentioned above, i.e, i want the $ sign to be considered only if it is between messages (like this
} $ { ) and to be left with the text untouched if it is inside the message text.
Will be very grateful if sum1 can provide a solution.

wanted output :
Quote:
{:1:abcd :2: me $myself im}{ aloneshell}
{scripting: hiho$w are you}{hopeur fine}
{im: great}
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to extract a string value from the given line

Hi I have an input as follows: param1:value1|param2:value2|param3:value3|param4:value4|param5:value5 where, "|" and ":" are delimiters Now suppose, I want to extract the value corresponding to "param4", i.e. "value4" in this case. In case we use awk, I want to use the value in shell... (1 Reply)
Discussion started by: gaurav_1711
1 Replies

2. Shell Programming and Scripting

ignoring blank line in a file

i have a file called Cleaner1.log . This files have some blank lines also.My requirement is that it should ignore the blank lines and give me the lines that contain some data. I m using this logic in a script: below the contents of file : Maximum Time Taken for Processing(Failed) RR... (4 Replies)
Discussion started by: ali560045
4 Replies

3. Shell Programming and Scripting

extract string from varying delimiter line

Hi I have lines like this a=1, b=2, c=3, a=1, d=4, e=5, b=225, I need to extract the b=nnn... value. I dont know how many other entries will be before and after it in each line. Ive tried a basic line like awk '/b=/, $NF ~ /,/ ' myfile.txt but I think that it doesnt care which comma it... (5 Replies)
Discussion started by: rebelbuttmunch
5 Replies

4. Shell Programming and Scripting

Perl REGEX - How do extract a string in a line?

Hi Guys, In the following line: cn=portal.090710.191533.428571000,cn=groups,dc=mp,dc=rj,dc=gov,dc=br I need to extract this string: portal.090710.191533.428571000 As you can see this string always will be bettween "cn=" and "," strings. Someone know one regular expression to... (4 Replies)
Discussion started by: maverick-ski
4 Replies

5. Shell Programming and Scripting

Extract a string from a line

Hiee all Can anyone tell me how to extract a string from a given line. STAPISDK_RELEASE_32_BL012_2011_JAN_25.1597 I want to extract BL012 from above. as 102 keeps on changing i want smthing like that it extract BL and 102 extrct by its own. Thankx guyzz (9 Replies)
Discussion started by: abhijtr
9 Replies

6. Shell Programming and Scripting

Extract string from multiple file based on line count number

Hi, I search all forum, but I can not find solutions of my problem :( I have multiple files (5000 files), inside there is this data : FILE 1: 1195.921 -898.995 0.750312E-02-0.497526E-02 0.195382E-05 0.609417E-05 -2021.287 1305.479-0.819754E-02 0.107572E-01 0.313018E-05 0.885066E-05 ... (15 Replies)
Discussion started by: guns
15 Replies

7. Post Here to Contact Site Administrators and Moderators

Want a tcl script to compare a string in a file ignoring white spaces

Hi , I want a tcl script to search a string ignoring whitespaces in a .log file . It should correctly match . The string are as follows "Output-Maps 1 1 0 0 0" 1 and Active Intermediate-Maps 0 0 0 ... (1 Reply)
Discussion started by: kulua
1 Replies

8. Shell Programming and Scripting

How to extract text from STRING to end of line?

Hi I have a very large data file with several hundred columns and millions of lines. The important data is in the last set of columns with variable numbers of tab delimited fields in front of it on each line. Im currently trying sed to get the data out - I want anything beetween :RES and... (4 Replies)
Discussion started by: Manchesterpaul
4 Replies

9. Shell Programming and Scripting

How to extract work in line string.?

Hello all, Soon I will be receiving a new file. I've asked the source system to put "TRAILER.1+0000007+1" for the trailer to indicate full receipt of file. I need to know how to separate TRAILER so I can use it in a if statement. I used the tail command but not sure how to incorporate awk or... (11 Replies)
Discussion started by: pone2332
11 Replies

10. UNIX for Beginners Questions & Answers

Extract a portion of string from each line in Linux

Hi I have to extract the destination path information from each record the file is of variable length so I will not be able to use the print command.The search should start on variable "destinationPath" and it should end at immediate "," also the first field has to be printed Input File:... (7 Replies)
Discussion started by: rkakitapalli
7 Replies
PPI::Token::QuoteLike(3)				User Contributed Perl Documentation				  PPI::Token::QuoteLike(3)

NAME
PPI::Token::QuoteLike - Quote-like operator abstract base class INHERITANCE
PPI::Token::QuoteLike isa PPI::Token isa PPI::Element DESCRIPTION
The "PPI::Token::QuoteLike" class is never instantiated, and simply provides a common abstract base class for the five quote-like operator classes. In PPI, a "quote-like" is the set of quote-like things that exclude the string quotes and regular expressions. The subclasses of "PPI::Token::QuoteLike" are: qw{} - PPI::Token::QuoteLike::Words `` - PPI::Token::QuoteLike::Backtick qx{} - PPI::Token::QuoteLike::Command qr// - PPI::Token::QuoteLike::Regexp <FOO> - PPI::Token::QuoteLike::Readline The names are hopefully obvious enough not to have to explain what each class is. See their pages for more details. You may note that the backtick and command quote-like are treated separately, even though they do the same thing. This is intentional, as the inherit from and are processed by two different parts of the PPI's quote engine. SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.3 2011-02-26 PPI::Token::QuoteLike(3)
All times are GMT -4. The time now is 06:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy