Sponsored Content
Top Forums Shell Programming and Scripting Removing LF and extracting two fields Post 302217210 by gugs on Tuesday 22nd of July 2008 07:51:34 AM
Old 07-22-2008
Removing LF and extracting two fields

I need some assistance, I am writing a script in bash.

I want to do two things:
1/. I want to replace the LF at the end of the RFH  Ĝ  ¸MQSTR ¸ so I can process the file record by record using a while loop.

2/. I want to extract two fields from each record, they are identified with tabs <RequestID></RequestID> and <error:Info></error:Info> from the sample data below.

In my file as shown below, each record in the file starts with: RFH  Ĝ  ¸MQSTR ¸ followed LF followed by the data:

RFH  Ĝ  ¸MQSTR ¸
<usr><SourceID>SYSA</SourceID><DSType>SPIResults</DSType><Source>SYSA</Source><Destina
tion>PortalSystem</Destination><RequestID>1000005</RequestID><TargetTablePrimaryKey>5</
TargetTablePrimaryKey><Replay><Original/><Current><DestinationSystemID>SYSA</DestinationSy
stemID></Current></Replay><TargetURI>SYSB</TargetURI><DestinationID>SYSA<
/DestinationID></usr> <mcd><Msd>xmlns</Msd></mcd> <?xml version="1.0"
encoding="UTF-8"?><error:Code>001</error:Code><error:Info>An error occured whilst trying
to process a routing request, see attached exception lists for
details</error:Info><error:OriginalExceptionData></mm:MessageMetadata><mf:MessageFormat SchemaVersion="1.0"><mf:MessageType><msg:Type>SPIResults</msg:Type><msg:Version>1.200</msg:Version>
RFH  Ĝ  ¸MQSTR ¸
<usr><SourceID>SYSA</SourceID><DSType>SPIResults</DSType><Source>SYSA</Source><Destina
tion>PortalSystem</Destination><RequestID>1000005</RequestID><TargetTablePrimaryKey>5</
TargetTablePrimaryKey><Replay><Original/><Current><DestinationSystemID>SYSA</DestinationSy
stemID></Current></Replay><TargetURI>SYSB</TargetURI><DestinationID>SYSA<
/DestinationID></usr> <mcd><Msd>xmlns</Msd></mcd> <?xml version="1.0"
encoding="UTF-8"?><error:Info>An error occured whilst trying to process a routing request,
see attached exception lists for details</error:Info><error:OriginalExceptionData>
RFH  Ĝ  ¸MQSTR ¸
<usr><SourceID>SYSA</SourceID><DSType>SPIResults</DSType><Source>SYSA</Source><Destina
tion>PortalSystem</Destination><RequestID>1000005</RequestID><TargetTablePrimaryKey>5</
TargetTablePrimaryKey><Replay><Original/><Current><DestinationSystemID>SYSA</DestinationSy
stemID></Current></Replay><TargetURI>SYSB</TargetURI><DestinationID>SYSA<
/DestinationID></usr> <mcd><Msd>xmlns</Msd></mcd> <?xml version="1.0"
encoding="UTF-8"?><error:Info>An error occured whilst trying to process a routing request,
see attached exception lists for details</error:Info></mm:MessageMetadata><mf:MessageFormat SchemaVersion="1.0"><mf:MessageType><msg:Type>SPIResults</msg:Type>
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting fields from an output 8-)

I am getting a variable as x=2006/01/18 now I have to extract each field from it. Like x1=2006, x2=01 and x3=18. Any idea how? Thanks a lot for help. Thanks CSaha (6 Replies)
Discussion started by: csaha
6 Replies

2. Shell Programming and Scripting

Removing certain fields from a file

Hi, I have a file namely 'inputs' The values inside the file are like this and seperated by a '|'. mani|21|CSE How can I extract the values from this file without the '|' symbol. Thanks in advance. (1 Reply)
Discussion started by: sendhilmani123
1 Replies

3. UNIX for Dummies Questions & Answers

Extracting information from text fields.

Dear friends, I'm a novice Unix user and I'm trying to learn the ropes. I have a big task I have to accomplish and I'm convinced Unix can get the job done, I just haven't figured out how. I recently posted on the topic of cutting text between unique text patterns and somebody helped me a great... (24 Replies)
Discussion started by: spindoctor
24 Replies

4. Shell Programming and Scripting

extracting fields

Hi, i have a line with several fields (indefinite number of - count varies) separated by colon. Now, i need to pick each field (except the first one) and have it assigned to variable within a loop. In other words, in the first iteration of the loop, the variable must be assigned with 2nd... (2 Replies)
Discussion started by: prvnrk
2 Replies

5. Shell Programming and Scripting

Extracting fields from file

I am need to extract a number of values from a file, put have now clue how to do this. The file looks like this: # My file Dest=87;CompatibleSystemSoftwareVersion=2.5300-; Dest=87;ImageVersion=000061f3;SystemSoftwareVersion=2.5300;CDN=http://my.backup.com/download.txt;CDN_Timeout=30; I... (3 Replies)
Discussion started by: MagicDude4Eva
3 Replies

6. Shell Programming and Scripting

need help in writing a script for extracting fields

Hi, I need to extract last character of the field retrieved from the database using select command. eg: select event,text from event_data; o/p: Event1,text1 But I need to extract only '1' from the fields...similarly '2' from Event2,text2 and '3' from Event3,text3 etc., and need to pass... (6 Replies)
Discussion started by: Rajesh Putnala
6 Replies

7. Shell Programming and Scripting

Help in extracting fields from a file

I have an input file with contents like: 203969 OrdAcctCycChg USAGE_DAEMON1 203970 OrdAcctCycChg USAGE_DAEMON2 203971 OrdAcctCycChg USAGE_DAEMON3 203972 OrdAcctCycChg USAGE_DAEMON4 I need to extract variables in first column... (51 Replies)
Discussion started by: Rajesh Putnala
51 Replies

8. Shell Programming and Scripting

Pattern Matching and extracting the required fields in Perl

Hi All, I am writing the following Perl Scrip and need your help in Pattern matching : I have the following Shell Script that would read line by line from the file (file_svn) and would inturn calls the Perl Script: #!/bin/bash perl_path="/home/dev/filter"... (2 Replies)
Discussion started by: filter
2 Replies

9. Shell Programming and Scripting

UNIX extracting fields

I have one file A.txt which is comma separated and I want to extract first 4 field's in a file and also I want to add one more column in output A.txt in output for all records. A.txt should not be hard coded since I do not filename it may be any file. (1 Reply)
Discussion started by: vamsi.valiveti
1 Replies

10. UNIX for Beginners Questions & Answers

Extracting specific fields from an XML file

Hello All, I have a requirement to split the input.xml file different files and i have tried using earlier examples(where i have posted in the forum), but still no luck Here is my input.xml <jms-system-resource> <name>UMSJMSSystemResource</name> ... (4 Replies)
Discussion started by: Siv51427882
4 Replies
WNPP-ALERT(1)                                                 General Commands Manual                                                WNPP-ALERT(1)

NAME
wnpp-alert - check for installed packages up for adoption or orphaned SYNOPSIS
wnpp-alert [--diff] [package ...] wnpp-alert --help|--version DESCRIPTION
wnpp-alert downloads the lists of packages which have been orphaned (O), are up for adoption (RFA), or the maintainer has asked for help (RFH) from the WNPP webpages, and then outputs a list of packages installed on the system, or matching the listed packages, which are in those lists. Note that WNPP, and therefore wnpp-alert's output, is source package based. OPTIONS
--diff, -d If the ~/.devscripts_cache directory exists, compare the output of wnpp-alert to the previous output (cached in the file wnpp-diff) and output the differences. --help, -h Show a summary of options. --version, -v Show version and copyright information. SEE ALSO
http://www.debian.org/devel/wnpp AUTHOR
wnpp-alert was written by Arthur Korn <arthur@korn.ch> and modified by Julian Gilbey <jdg@debian.org> for the devscripts package. It is in the public domain. DEBIAN Debian Utilities WNPP-ALERT(1)
All times are GMT -4. The time now is 06:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy