Sponsored Content
Top Forums Shell Programming and Scripting command/script to extract a substring from a string Post 302089787 by girisha on Wednesday 20th of September 2006 08:36:34 PM
Old 09-20-2006
command/script to extract a substring from a string

I have a long string "<ID type="Oid">{[ManagedElement(Key=rvpdn-nvl-mayo-17)][PhysicalRoot][Chassis][Slot(SlotNum=10000)][Module][Port(PortNumber=GigabitEthernet0/1)][PhysicalLayer][DataLinkLayer]}</ID>"

I need to extract "GigabitEthernet0/1" from the above string.
How can it be done? Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using Awk in shell script to extract an index of a substring from a parent string

Hi All, I am new to this shell scripting world. Struck up with a problem, can anyone of you please pull me out of this. Requirement : Need to get the index of a substring from a parent string Eg : index("Sandy","dy") should return 4 or 3. My Approach : I used Awk function index to... (2 Replies)
Discussion started by: sandeepms17
2 Replies

2. Shell Programming and Scripting

help for shell script of finding shortest substring from given string by user

please give me proper solution for finding a shortest substring from given string if string itself and first char and last char of that substr are also given by user if S="dpoaoqooroo" and FC="o" and LC="o",then shortest substr is "oo" and rest of the string is "dpoaoqroo" i have code but it is... (1 Reply)
Discussion started by: pankajd
1 Replies

3. UNIX for Dummies Questions & Answers

Extract substring of unknown length from string

I have a string: hgLogOutput=" +0000 files: forum/web/hook-test.txt /forum/web/hook-test-2.txt description: test" and I want to extract the file names from it, they will always appear between the files: and the description:. I have worked out that I can do this: "$hgLogOutput" | awk '{... (2 Replies)
Discussion started by: klogger
2 Replies

4. Solaris

Extract substring from a string

i have srtring i.e. "NAME,CLASS,AGE" (length of string is not constant) and from this string i've extract each word delimited by "," (comma). INPUT: "NAME,CLASS,AGE" OUTPUT: NAME CLASS AGE how can i do that? i have tried some string manipulation function like... (5 Replies)
Discussion started by: jadoo_c2
5 Replies

5. Shell Programming and Scripting

Extract a string up to the first occurence of a substring

Hi, I'm a newbie to shell scripting and have searched the forum but couldn't find what i was looking for. Basically I have a list of filenames like... 123-fileone.txt I want to be able to extract the prefix up to the first '-'. So I'd end up with 123. I have attempted it using a pretty... (2 Replies)
Discussion started by: kirkg
2 Replies

6. Shell Programming and Scripting

How to extract a substring from a string

Hi, I have an input string say for example: ABC,DEF,IJK,LMN,...,XYZ The above string is comma delimited. Now I have to extract the last part after the comma i.e. XYZ. :b: (3 Replies)
Discussion started by: bghosh
3 Replies

7. Shell Programming and Scripting

Help me please: UNIX command to extract substring not squeeze spaces

Hi experts, Please help me!... I have a string " test1 test2 test3 ". There are two spaces before "test1"; There are four spaces between "test1" and "test2"; there are two spaces between "test2 and "test3". I want to extract a substring "2 test3" using positions. Below is my test... (5 Replies)
Discussion started by: sophiez16
5 Replies

8. Shell Programming and Scripting

Command to extract word from a string

Hi All, I have a word and from that word would like to search for certain set of string, is there any command to do so ? EX : Components from the above word, would like to search for strings set and extract the search string and then do if stmt... pon nen ent Com say... (2 Replies)
Discussion started by: Optimus81
2 Replies

9. Shell Programming and Scripting

Script Shell Extract substring

Hi all, Please, i'd like to extract string just before '.fr'. Here is some lines of my file: g-82.text.text1.fr.worker1 g-xx.yyyyyy.zzzz.fr.worker2 i'd like to extract this text: g-82.text.text1 g-xx.yyyyyy.zzzz Please, which command i have to use in my script shell ? ... (16 Replies)
Discussion started by: chercheur111
16 Replies

10. UNIX for Beginners Questions & Answers

Question on grep command (extract a string)

Dear all, I have a file a.txt like below: 1_234560_A_G_b37 1 2 1 2 2 2 ... 1_35465767_C_T_b37 2 1 1 2 2 2 ... 2_490638010_A_T_b37 1 2 1 2 2 2 ... 10_4567899_T_G_b37 2 2 1 2 2 2 ... ... what I want to do is extracting rows starting with "10_" like : 10_4567899_T_G_b37 2 2 1 2 2... (1 Reply)
Discussion started by: forevertl
1 Replies
nvlist_add_boolean(3NVPAIR)				 Name-value Pair Library Functions			       nvlist_add_boolean(3NVPAIR)

NAME
nvlist_add_boolean, nvlist_add_boolean_value, nvlist_add_byte, nvlist_add_int8, nvlist_add_uint8, nvlist_add_int16, nvlist_add_uint16, nvlist_add_int32, nvlist_add_uint32, nvlist_add_int64, nvlist_add_uint64, nvlist_add_string, nvlist_add_nvlist, nvlist_add_nvpair, nvlist_add_boolean_array, nvlist_add_byte_array, nvlist_add_int8_array, nvlist_add_uint8_array, nvlist_add_int16_array, nvlist_add_uint16_array, nvlist_add_int32_array, nvlist_add_uint32_array, nvlist_add_int64_array, nvlist_add_uint64_array, nvlist_add_string_array, nvlist_add_nvlist_array - add new name-value pair to nvlist_t SYNOPSIS
cc [ flag... ] file... -lnvpair [ library... ] #include <libnvpair.h> int nvlist_add_boolean(nvlist_t *nvl, const char *name); int nvlist_add_boolean_value(nvlist_t *nvl, const char *name, boolean_t val); int nvlist_add_byte(nvlist_t *nvl, const char *name, uchar_t val); int nvlist_add_int8(nvlist_t *nvl, const char *name, int8_t val); int nvlist_add_uint8(nvlist_t *nvl, const char *name, uint8_t val); int nvlist_add_int16(nvlist_t *nvl, const char *name, int16_t val); int nvlist_add_uint16(nvlist_t *nvl, const char *name, uint16_t val); int nvlist_add_int32(nvlist_t *nvl, const char *name, int32_t val); int nvlist_add_uint32(nvlist_t *nvl, const char *name, uint32_t val); int nvlist_add_int64(nvlist_t *nvl, const char *name, int64_t val); int nvlist_add_uint64(nvlist_t *nvl, const char *name, uint64_t val); int nvlist_add_string(nvlist_t *nvl, const char *name, const char *val); int nvlist_add_nvlist(nvlist_t *nvl, const char *name, nvlist_t *val); int nvlist_add_nvpair(nvlist_t *nvl, nvpair_t *nvp); int nvlist_add_boolean_array(nvlist_t *nvl, const char *name, boolean_t *val, uint_t nelem); int nvlist_add_byte_array(nvlist_t *nvl, const char *name, uchar_t *val, uint_t nelem); int nvlist_add_int8_array(nvlist_t *nvl, const char *name, int8_t *val, uint_t nelem); int nvlist_add_uint8_array(nvlist_t *nvl, const char *name, uint8_t *val, uint_t nelem); int nvlist_add_int16_array(nvlist_t *nvl, const char *name, int16_t *val, uint_t nelem); int nvlist_add_uint16_array(nvlist_t *nvl, const char *name, uint16_t *val, uint_t nelem); int nvlist_add_int32_array(nvlist_t *nvl, const char *name, int32_t *val, uint_t nelem); int nvlist_add_uint32_array(nvlist_t *nvl, const char *name, uint32_t *val, uint_t nelem); int nvlist_add_int64_array(nvlist_t *nvl, const char *name, int64_t *val, uint_t nelem); int nvlist_add_uint64_array(nvlist_t *nvl, const char *name, uint64_t *val, uint_t nelem); int nvlist_add_string_array(nvlist_t *nvl, const char *name, char *const *val, uint_t nelem); int nvlist_add_nvlist_array(nvlist_t *nvl, const char *name, nvlist_t **val, uint_t nelem); PARAMETERS
nvl The nvlist_t (name-value pair list) to be processed. nvp The nvpair_t (name-value pair) to be processed. name Name of the nvpair (name-value pair). nelem Number of elements in value (that is, array size). val Value or starting address of the array value. DESCRIPTION
These functions add a new name-value pair to an nvlist_t. The uniqueness of nvpair name and data types follows the nvflag argument speci- fied for nvlist_alloc(). See nvlist_alloc(3NVPAIR). If NV_UNIQUE_NAME was specified for nvflag, existing nvpairs with matching names are removed before the new nvpair is added. If NV_UNIQUE_NAME_TYPE was specified for nvflag, existing nvpairs with matching names and data types are removed before the new nvpair is added. If neither was specified for nvflag, the new nvpair is unconditionally added at the end of the list. The library preserves the order of the name-value pairs across packing, unpacking, and duplication. Multiple threads can simultaneously read the same nvlist_t, but only one thread can actively change a given nvlist_t at a time. The caller is responsible for the synchronization. The nvlist_add_boolean() function is deprecated. The nvlist_add_boolean_value() function should be used instead. RETURN VALUES
These functions return 0 on success and an error value on failure. ERRORS
These functions will fail if: EINVAL There is an invalid argument. ENOMEM There is insufficient memory. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +----------------------------+------------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +----------------------------+------------------------------+ |Interface Stability | Evolving | +----------------------------+------------------------------+ |MT-Level | MT-Safe | +----------------------------+------------------------------+ SEE ALSO
libnvpair(3LIB), attributes(5) SunOS 5.10 2 Feb 2004 nvlist_add_boolean(3NVPAIR)
All times are GMT -4. The time now is 01:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy