Sponsored Content
Full Discussion: Parsing char string
Top Forums Shell Programming and Scripting Parsing char string Post 302222747 by joeyg on Thursday 7th of August 2008 01:03:09 PM
Old 08-07-2008
Tools Does the following help?

Code:
> echo '-Ort' | awk '{print substr($0,2,1)}'
O
> echo '-Ort' | awk '{print substr($0,3,1)}'
r
> echo '-Ort' | awk '{print substr($0,4,1)}'
t

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

string of 7 char length always...

Hi, I know, particular value in the variable should always be of lenth 7 , but the value that is present in thevariable might be of any no.of characters less than or equal to 7... if the no.of characters in the variable is less than 7, I want to add, zeroes at the starting of the field.. How can... (3 Replies)
Discussion started by: thanuman
3 Replies

2. Programming

replacing char with string

how we can replace char with a string example char *a="a.s" so finally what i ant to do raplace a with ant and s sree so in my array a i want to store the value as "ant.sree" thank u in advance (1 Reply)
Discussion started by: phani_sree
1 Replies

3. Shell Programming and Scripting

last char from a string

i have a script that reads a plain text file. (its a ksh, and i can use bash also) each line of the file is a fullpath of a file. that makes the list huge. i need to add a functionalitie to that script, i have to be able to add /usr/* or /usr/ and with that reference all the files and folders... (6 Replies)
Discussion started by: broli
6 Replies

4. Shell Programming and Scripting

how to get number char from a string

for example: i hav a string like : /rmsprd/arch01/rmsprd/rmsprdarch72736.log how I can extract my_num=72736? I know I can echo "/rmsprd/arch01/rmsprd/rmsprdarch72736.log" | tr "/" " " | awk '{ print $4 }' to get rmsprdarch72736.log (4 Replies)
Discussion started by: netbanker
4 Replies

5. Shell Programming and Scripting

Parsing X char from right to left

I am new to bash scripts I need something quite easy to do in VBS, When I wanted to get the first 5 chars I used funcition right(5,strGet) how can I do the same in bash? I am trying to get the MAC address in Ubuntu I have done so far ifconfig wlan2 | grep HWaddr | awk '{print $5}' | sed -e... (3 Replies)
Discussion started by: 4scriptmoni
3 Replies

6. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

7. Shell Programming and Scripting

How to loop through every char in a string

for example this string: gLZMQp8i Loop become easy if we add space between each char, How to do it? or other solutions are welcome. (9 Replies)
Discussion started by: honglus
9 Replies

8. Shell Programming and Scripting

Parsing a long string string problem for procmail

Hi everyone, I am working on fetchmail + procmail to filter mails and I am having problem with parsing a long line in the body of the email. Could anyone help me construct a reg exp for this string below. It needs to match exactly as this string. GetRyt... (4 Replies)
Discussion started by: cwiggler
4 Replies

9. Programming

C++ Using open on a string instead of char*

I am using ifstream to open a file using std::fstream::open void open ( const char * filename, ios_base::openmode mode = ios_base::in ); However I want to use a string instead of a char* as follows but having a problem on how to do this string val_ifmodl = “fred.modl” ifstream ifs_modl;... (2 Replies)
Discussion started by: kristinu
2 Replies

10. Shell Programming and Scripting

Parsing of Char and Numeric in a file

Hi All, i'm working on some report and currently have this plain text file generated. server_name1|sdfd1deal | 1048572| 1040952| 99| 207| 1| 1 server_name1|dba1dbs | 83886048| 40730796| 48| 5762| 22764| 8... (4 Replies)
Discussion started by: fedora132010
4 Replies
XmParseMapping(library call)											      XmParseMapping(library call)

NAME
XmParseMapping -- Data type for a compound string parse mapping SYNOPSIS
#include <Xm/Xm.h> DESCRIPTION
XmParseMapping is an opaque data type for a parse mapping used by XmStringParseText to create a compound string. A parse mapping contains a pattern to be matched in text being parsed to create a compound string. It also contains a compound string, or a function to be invoked to provide a compound string, to be included in the compound string being created whenever the pattern is matched. An application uses a resource-style interface to specify components for an XmParseMapping. XmParseMappingCreate creates a parse mapping, using a resource-style argument list. XmParseMappingGetValues and XmParseMappingSetValues retrieve and set the components of a parse map- ping. XmParseMappingFree recovers memory used by a parse mapping. XmParseTable is an array of XmParseMapping objects. The XmNinvokeParseProc resource is a function of type XmParseProc, which is defined as follows: XmIncludeStatus (*XmParseProc) (text_in_out, text_end, type, tag, entry, pattern_length, str_include, call_data) XtPointer *text_in_out; XtPointer text_end; XmTextType type; XmStringTag tag; XmParseMapping entry; int pattern_length; XmString *str_include; XtPointer call_data; A parse procedure provides an escape mechanism for arbitrarily complex parsing. This procedure is invoked when a pattern in the input text is matched with a pattern in a parse mapping whose XmNincludeStatus is XmINVOKE. The input text is a pointer to the first byte of the pattern that was matched to trigger the call to the parse procedure. The parse proce- dure consumes as many bytes of the input string as it needs and sets the input text pointer to the following byte. It returns a compound string to be included in the compound string being constructed, and it also returns an XmIncludeStatus indicating how the returned compound string should be handled. If the parse procedure does not set the input text pointer ahead by at least one byte, the parsing routine con- tinues trying to match the input text with the patterns in the remaining parse mappings in the parse table. Otherwise, the parsing routine begins with the new input text pointer and tries to match the input text with patterns in the parse mappings starting at the beginning of the parse table. text_in_out Specifies the text being parsed. The value is a pointer to the first byte of text matching the pattern that triggered the call to the parse procedure. When the parse procedure returns, this argument is set to the position in the text where parsing should resume--that is, to the byte following the last character parsed by the parse procedure. text_end Specifies a pointer to the end of the text_in_out string. If text_end is NULL, the string is scanned until a NULL character is found. Otherwise, the string is scanned up to but not including the character whose address is text_end. type Specifies the type of text and the tag type. If a locale tag should be created, type has a value of either XmMULTIBYTE_TEXT or XmWIDECHAR_TEXT. If a charset should be created, type has a value of XmCHARSET_TEXT. tag Specifies the tag to be used in creating the result. The type of string tag created (charset or locale) depends on the text type and the passed in tag value. If the tag value is NULL and if type indicates that a charset string tag should be created, the string tag has the value that is the result of mapping XmSTRING_DEFAULT_CHARSET. If type indicates a locale string tag, the string tag has the value _MOTIF_DEFAULT_LOCALE. entry Specifies the parse mapping that triggered the call to the parse procedure. pattern_length Specifies the number of bytes in the input text, following text_in_out, that constitute the matched pattern. str_include Specifies a pointer to a compound string. The parse procedure creates a compound string to be included in the compound string being constructed. The parse procedure then returns the compound string in this argument. call_data Specifies data passed by the application to the parsing routine. The parse procedure returns an XmIncludeStatus indicating how str_include is to be included in the compound string being constructed. Fol- lowing are the possible values: XmINSERT Concatenate the result to the compound string being constructed and continue parsing. XmTERMINATE Concatenate the result to the compound string being constructed and terminate parsing. New Resources The following table defines a set of resources used by the programmer to specify data. The codes in the access column indicate if the given resource can be set at creation time (C), set by using XmParseMappingSetValues (S), retrieved by using XmParseMappingGetValues (G), or is not applicable (N/A). +-----------------------------------------------------------------------+ | | XmParseMapping Resource Set | | |Name | Class | Type | Default | Access | +-------------------+-------+-----------------+----------------+--------+ |XmNclientData | | XtPointer | NULL | CSG | +-------------------+-------+-----------------+----------------+--------+ |XmNincludeStatus | | XmIncludeStatus | XmINSERT | CSG | +-------------------+-------+-----------------+----------------+--------+ |XmNinvokeParseProc | | XmParseProc | NULL | CSG | +-------------------+-------+-----------------+----------------+--------+ |XmNpattern | | XtPointer | NULL | CSG | +-------------------+-------+-----------------+----------------+--------+ |XmNpatternType | | XmTextType | XmCHARSET_TEXT | CSG | +-------------------+-------+-----------------+----------------+--------+ |XmNsubstitute | | XmString | NULL | CSG | +-------------------+-------+-----------------+----------------+--------+ +-------------------+-------+-----------------+----------------+--------+ XmNclientData Specifies data to be used by the parse procedure. XmNincludeStatus Specifies how the result of the mapping is to be included in the compound string being constructed. Unless the value is XmIN- VOKE, the result of the mapping is the value of XmNsubstitute. Following are the possible values for XmNincludeStatus: XmINSERT Concatenate the result to the compound string being constructed and continue parsing. XmINVOKE Invoke the XmNinvokeParseProc on the text being parsed and use the returned compound string instead of XmNsubstitute as the result to be inserted into the compound string being constructed. The include status returned by the parse proce- dure (XmINSERT or XmTERMINATE) determines how the returned compound string is included. XmTERMINATE Concatenate the result to the compound string being constructed and terminate parsing. XmNinvokeParseProc Specifies the parse procedure to be invoked when XmNincludeStatus is XmINVOKE. XmNpattern Specifies a pattern to be matched in the text being parsed. This is a maximum of one character. XmNpatternType Specifies the type of the pattern that is the value of XmNpattern. Following are the possible values: o XmCHARSET_TEXT o XmMULTIBYTE_TEXT o XmWIDECHAR_TEXT XmNsubstitute Specifies the compound string to be included in the compound string being constructed when XmNincludeStatus is XmINSERT or XmTER- MINATE. RELATED
XmParseMappingCreate(3), XmParseMappingFree(3), XmParseMappingGetValues(3), XmParseMappingSetValues(3), XmParseTable(3), and XmString(3). XmParseMapping(library call)
All times are GMT -4. The time now is 11:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy