Sponsored Content
Top Forums Shell Programming and Scripting To extract a string between two words in XML file Post 302815755 by Padmanabhan on Saturday 1st of June 2013 09:52:19 PM
Old 06-01-2013
hi it works perfect.thanks a lotSmilieSmilie
i have one more requirement.I have modified the extracted data in a file and and i need to insert in the place exactly where i take from.
i.e between <PersonInfoShipTo and />
thanks for ur help.Smilie
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

To Extract words from File based on Position

Hi Guys, While I was writing one shell script , I just got struck at this point. I need to extract words from a file at some specified position and do some comparison operation and need to replace the extracted word with another word. Eg : I like Orange very much. I need to replace... (19 Replies)
Discussion started by: kuttu123
19 Replies

2. Shell Programming and Scripting

[sed] extract words from a string

Hi, One of the scripts creates logs in the format: progname_file1.log.20100312020657 where after file the number could be from 1 to 28 and after log. the date is attached in the format YYYYMMDDHHMISS progname_file<1-28>.log.YYYYMMDDHHMISS. Now I want to discard the .20100312020657... (7 Replies)
Discussion started by: dips_ag
7 Replies

3. UNIX for Dummies Questions & Answers

Extract words to new file

Hi there, Unix Gurus Working with big listings of english sentences for my pupils, of the type: 1. If the boss's son had been , someone would have asked for money by now. 2. Look, I haven't a crime, so why can't you let me go? .... I wondered how to extract the words between brackets in... (7 Replies)
Discussion started by: eldeingles
7 Replies

4. Shell Programming and Scripting

XML - Split And Extract String between Chars

Hi, I am trying to read the records from file and split into multiple files. SourceFile.txt <?xml version="1.0" encoding="UTF-8"?>... (2 Replies)
Discussion started by: unme
2 Replies

5. Shell Programming and Scripting

Extract string from XML

Hi, I wish to grep for the first instance of <listen-address> value between the first <server></server> tag in an xml file. Sample xml: ......... <timeout-seconds>1500</timeout-seconds> </jta> <server> <name>Adminserver_DEV</name> ... (9 Replies)
Discussion started by: mohtashims
9 Replies

6. Shell Programming and Scripting

Extract a particular xml only from an xml jar file

Hi..need help on how to extract a particular xml file only from an xml jar file... thanks! (2 Replies)
Discussion started by: qwerty000
2 Replies

7. Shell Programming and Scripting

I need to extract uique words from text file

Hello programmers, I need to create a list of unique words from a text file using PERL...may i have the code for that please? Thank you (1 Reply)
Discussion started by: alsohari
1 Replies

8. Shell Programming and Scripting

Extract words starting with a pattern from a file

Hi Guys.. I have a file and i want to extract all words that starts with a pattern 'ABC_' or 'ADF_' For example, ABC.txt ---- INSERT INTO ABC_DLKFJAL_FJKLD SELECT DISTINCT S,B,C FROM ADF_DKF_KDFJ_IERU8 A, ABC_LKDJFREUE9_FJKDF B WHERE A.FI=B.EI; COMMIT; Output : ABS_DLKFJAL_FJKLD,... (5 Replies)
Discussion started by: Pramod_009
5 Replies

9. Shell Programming and Scripting

How can I extract XML block around matching search string?

I want to extract XML block surrounding search string Ex: print XML block for string "myapp1-ear" surrounded by "<application> .. </application>" Input XML: <?xml version="1.0" encoding="UTF-8"?> <deployment-request> <requestor> <first-name>kchinnam</first-name> ... (16 Replies)
Discussion started by: kchinnam
16 Replies

10. UNIX for Beginners Questions & Answers

Shell - Read a text file with two words and extract data

hi I made this simple script to extract data and pretty much is a list and would like to extract data of two words separated by commas and I would like to make a new text file that would list these extracted data into a list and each in a new line. Example that worked for me with text file... (5 Replies)
Discussion started by: dandaryll
5 Replies
patterns(5int)															    patterns(5int)

Name
       patterns - patterns for use with internationalization tools

Syntax
       See the Description section.

Description
       The patterns file contains the patterns that must be matched for the internationalization tools and

       The pattern file in the following example is the default patterns file located in

       # This is the header to insert at the beginning of the first new
       # source file

       $SRCHEAD1(1)
       #include <nl_types.h>
       nl_catd _m_catd;
       

       # The header to insert at the beginning of the rest of the new
       # source files

       $SRCHEAD2(2)
       #include <nl_types.h>
       extern nl_catd _m_catd;
       

       # This is the header to insert at the beginning of the message
       # catalogues

       $CATHEAD(3)
       $ /*
       $  * X/OPEN message catalogue
       $  */
       
       $quote "

       # This is how patterns that are matched will get rewritten.

       $REWRITE(4)
       catgets(_m_catd, %s, %n, %t)

       # Following is a list of the sort of strings we are looking for.
       # The regular expression syntax is based on regex(3).

       $MATCH(5)

       # Match on strings containing an escaped "
       "[^\]*\"[^"]*"

       # Match on general strings
       "[^"]*"

       # Now reject some special C constructs.

       $REJECT(6)
       # the empty string
       ""0

       # string with just one format descriptor
       "%."
       "%.."

       # string with just line control in
       "\."

       # string with just line control and one format descriptor in
       "%.\."
       "\.%."

       # ignore cpp include lines
       #[  ]*include[	]*".*"
       #[  ]*ident[  ]*".*"

       # reject some common C functions and expressions with quoted
       # strings
       [sS][cC][cC][sS][iI][dD][][  ]*=[  ]*".*"
       open[  ]*([^,]*,[^)]*)
       creat[  ]*([^,]*,[^)]*)
       access[	]*([^,]*,[^)]*)
       chdir[  ]*([^,]*,[^)]*)
       chmod[  ]*([^,]*,[^)]*)
       chown[  ]*([^,]*,[^)]*)

       # Reject any strings in single line comments
       /*.**/

       # Print a warning for initialised strings.

       $ERROR initialised strings cannot be replaced(7)
       char[^=]*=[  ]*"[^"]*"
       char[^=]*=[  ]*"[^\]*\"[^"]*"
       char[ ]***[A-Za-z][A-Za-z0-9]*[[^]*][ ]*=[  {]*"[^"]*"
       char[ ]***[A-Za-z][A-Za-z0-9]*[[^]*][ ]*=[  {]*"[^\]*\"[^"]*"

       The default patterns file is divided into the following sections:(1)  In	the $SRCHEAD1 section, the and commands place text in this section at the beginning of the first new source program, which is pre-
	    fixed by These commands define the native language file descriptors that point to the message catalog.(2)  In the $SRCHEAD2 section, the and commands place text in this section at the beginning of the second and  remaining  source  programs.
	    These  commands  also  define  the native language file descriptors that point to the message catalog. $SRCHEAD2 contains the external
	    declaration of the nl file descriptor.(3)  In the $CATHEAD section, the and commands place text in this section at the beginning of the message catalog.(4)  In the $REWRITE section, you specify how the and commands should replace the extracted strings in the new source program. You can sup-
	    ply three options to the command:

	    %s	 This  option increments the set number for each source. This option applies only if you are using the command.  For more informa-
		 tion on set numbers, see the reference page.

	    %n	 This option increments the message number for each string extracted. This option applies if you are using either the or commands.

	    %t	 This option expands the text from the string extracted. The string can be a error message or the  default  string  extracted  and
		 printed  by the command. For example, if you want an error message to appear when is unable to retrieve the message from the mes-
		 sage catalog, you would include the following line:
		 catgets(_m_catd, %s, %n, "BAD STRING")

		 When fails, it returns the message BAD STRING.(5)  In the $MATCH section, you specify the patterns in the form of a regular expression that you want the and commands to find and  match.
	    The regular expression follows the same syntax rules as defined in reference page.(6)  In	the $REJECT section, you specify the matched strings that you do not want the and commands to replace in your source program.  The
	    regular expression follows the same syntax rules as defined in reference page.(7)  In the $ERROR section, the and commands look for bad matches and notify you with a warning message. The regular expression follows the
	    same syntax rules as defined in the reference page.

See Also
       intro(3int), extract(1int), strextract(1int), strmerge(1int), trans(1int), regex(3)
       Guide to Developing International Software

																    patterns(5int)
All times are GMT -4. The time now is 02:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy