Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to select text within the second ()? Post 302461412 by Tytalus on Monday 11th of October 2010 06:31:00 AM
Old 10-11-2010
couple of ways:

Code:
#  str="some message (string A) some message (string B) some message (string C) some message (string D) some message (string E)"

#  echo $str|nawk -F"[()]" '{print $3}'
string B

#  echo $str | sed 's/[^(]*([^(]*(\([^)]*\)).*/\1/'
string B

HTH
This User Gave Thanks to Tytalus For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Select text within matching ( ) bracket

Hi, I am looking for a simple command to select text within a open bracket "(" and a matching close bracket ")" and output the within-bracket-text to a file. This function is similar to the common vi select a range of text with "(" to ")" but not sure how to run the same function in command... (4 Replies)
Discussion started by: cursive
4 Replies

2. Shell Programming and Scripting

Select block of text around matching braces

Hi, I have several block of text that I need to select, however this text may be spread over several lines and contains the '{' and '}' within it. For e.g., ABC=100{ DEF = 200 { GHI, JKL } } #2nd Block 123 { 456{78,910}} }I am trying to figure out how to remove... (2 Replies)
Discussion started by: BootComp
2 Replies

3. Shell Programming and Scripting

random select text file ranamed

i want to need script.. source.txt /home/user1/public_html/test3 /home/user90/public_html/test9 . . . /home/user650/public_html/test000 read source.txt and cd /home/user**/public_html/*** and there is 1.txt, 2txt ~~25.txt and select 6 text files randomly among the... (4 Replies)
Discussion started by: topic32428285
4 Replies

4. Shell Programming and Scripting

select some text from a test dependng on pattern

I have some absolute file location $INSTALL_BASEPATH/onereview-5.0/resources/commons-messages/commonmessages_default.properties $INSTALL_BASEPATH/onereview-5.0/orv-deploy/config-console.war/WEB-INF/classes/com/connectiva/configuration/console/resource/configurationBundle.properties I need to... (3 Replies)
Discussion started by: mnmonu
3 Replies

5. Shell Programming and Scripting

search & select text

hi people; from my file:... ... ... 101221-18:45:17 192.168.1.1 1.0 PortNodeModel ========================================================= Object Attribute Value ========================================================= SectorPort=3 switchport 20 SectorPort=1 switchport 10 SectorPort=2... (12 Replies)
Discussion started by: gc_sw
12 Replies

6. Shell Programming and Scripting

Like to select text in a From/To list

Hi I need help to configure AWK to find a string based From/To filed I have a table like this 0A00 - 0AFF Nuts 0B00 - 0BFF Bolt If I have in a program a value like "0B22" I wold like to get "Bolt" in return. List are in Hex Still try to learn AWK :) (3 Replies)
Discussion started by: Jotne
3 Replies

7. UNIX for Dummies Questions & Answers

How to randomly select lines from a text file

I have a text file with 1000 lines, I want to randomly select 200 lines from it and print them as output. How do I go about doing that? Thanks! (7 Replies)
Discussion started by: evelibertine
7 Replies

8. Shell Programming and Scripting

Parse SQL text and only format first SELECT statement.

Hi Forum. Need your expertise on the following question. I have the following file which I would like to parse, find first block of SELECT statment and concatenate all input fields as 1 field (~ delimited): Old File: SELECT /*+ USE_HASH(CCOMM ICAR IMAP IAS IP IMAS IMPS IAP SPCA) */ ... (5 Replies)
Discussion started by: pchang
5 Replies

9. Shell Programming and Scripting

Select row from file and text

Hi all! I would like to solve a problem but I have no clue of how do it!I will be grateful if someone could help me! Briefly I have a big file like this: >ENSMUSG00000000204 | ENSMUST00000159637 GGCGAGGCTTACGCCATTTTACCTCAGCGAGCATTCATAAAGCTGCGAGCATTCATACAG >ENSMUSG00000000204 |... (3 Replies)
Discussion started by: giuliangiuseppe
3 Replies

10. UNIX for Beginners Questions & Answers

Using grep to select specific patterns in text file?

How do I use grep to select words that start with I or O, end in box, and contain at least one letter in between them? the text file mailinfo.txt contains Inbox the Inbox Is a match box Doesn't match INBOX Outbox Outbox1 InbOX Ibox I box If the command works correctly it... (4 Replies)
Discussion started by: steezuschrist96
4 Replies
gettxt(3C)																gettxt(3C)

NAME
gettxt() - read text string from message file SYNOPSIS
DESCRIPTION
The routine retrieves a text string from a message file for the current locale. msg_id has the following syntax: where msgfilename is the name of the message file generated by mkmsgs(1). If msgfilename is NULL, uses the message file specified in the last call to setcat(3C). msgnumber is the sequence number of the text string in the message file (the sequence begins at 1). returns the message under any of the following conditions: o msgfilename is an invalid message catalog name. o No catalog is specified in msg_id or through setcat(3C). o msgnumber is not a positive number. o No message could be retrieved and def_str is NULL. EXTERNAL INFLUENCES
Environment Variables uses the environment variable to determine the locale to use to search for the msgfilename message file. If is not set, the environment variable is used. If is not set, the "C" locale will be used. The user can also change the locale via the setlocale(3C) routine. If the msgfilename message file is not found in the specified locale or if the msgnumber is out of bounds, attempts to retrieve the text string from the "C" locale. def_str is the string returned if a text string cannot be retrieved even from the "C" locale. EXAMPLES
The following code fragments are equivalent: WARNINGS
Obsolescent Interfaces is to be obsoleted at a future date. SEE ALSO
mkmsgs(1), setcat(3C), setlocale(3C), environ(5), thread_safety(5). STANDARDS COMPLIANCE
TO BE OBSOLETED gettxt(3C)
All times are GMT -4. The time now is 08:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy