parse data between parenthesis using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parse data between parenthesis using shell script
# 1  
Old 05-21-2009
parse data between parenthesis using shell script

Hi
I am using shell script and i need to parse the data between parenthesis.How do i do it using shell script.
Ex: section(name).
I want to extract name from the above string using shell script.
# 2  
Old 05-21-2009
what have you tried?
# 3  
Old 05-21-2009
For starters:

Code:
# echo "in(side)out" | cut -d ')' -f 1 - | cut -d '(' -f 2 -
side

# 4  
Old 05-21-2009
Quote:
Originally Posted by julie_s
Ex: section(name).
I want to extract name from the above string using shell script.
Code:
 
a="section(name).color(red)."
 
b="${a//*\((*)\)*/\1}"
echo "$b"
 
c=${a#*\(}
c=${c%%\)*}
echo "$c"

# 5  
Old 05-21-2009
Quote:
Originally Posted by dr.house
For starters:

Code:
# echo "in(side)out" | cut -d ')' -f 1 - | cut -d '(' -f 2 -
side

Hey thanks a lot Smilie ...
Its really working ....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a script to parse data and output to csv

I am not too savvy with arrays and am assuming that what I am looking for needs arrays. This is my requirement. So I have the raw data that gets updated to a log as shown below StudentInfo: FullInfo = { Address = Newark Age = 20 Name= John } StudentInfo:... (2 Replies)
Discussion started by: sidnow
2 Replies

2. Shell Programming and Scripting

The shell script doesn't get arguments, but parse them

Hello, I have a simple shell script, which starts from crontab like this: 00 03 * * 2-6 /export/applications/dte/sh/fwmarg.sh > /export/applications/dte/data/cron_log/fwmarg.cronlog.`date +\%m.\%d` 2>&1 The script doesn't get any argument. But inside it I see the line ... (10 Replies)
Discussion started by: digioleg54
10 Replies

3. UNIX for Beginners Questions & Answers

Extraction of data between parenthesis using multiple pattern

i want to extract all data with in parenthesis from a file by passing a pattern from another file.i have some sql statements in my file and i want to extract those ddl by refering to a pattern which is in another file and before writting into file i need some transformation to do.Basically i want... (1 Reply)
Discussion started by: raj121
1 Replies

4. Shell Programming and Scripting

How to Parse the XML data along with the URL in Shell Script?

Hi, Can anybody help to solve this. I want to parse some xmldata along with the URL in the Shell. I'm calling the URL via the curl command Given below is my shell script file export... (7 Replies)
Discussion started by: Megala
7 Replies

5. Shell Programming and Scripting

AWK script to parse a data in a file

Hi Unix gurus.. I have a file which has below data, It has several MQ Queue statistics; QueueName= 'TEST1' CreateDate= '2009-10-30' CreateTime= '13.45.40' QueueType= Predefined QueueDefinitionType= Local QMinDepth= 0 QMaxDepth= 0 QueueName= 'TEST2' CreateDate= '2009-10-30'... (6 Replies)
Discussion started by: dd_psg
6 Replies

6. Shell Programming and Scripting

Parse config file data to script variable

I have a script with few pre defined variables. Also have a config file. Something like this. # config file # Define Oracle User MOD1_TAG=abcde MOD2_TAG=xyzabc MOD3_TAG=def I need to parse the config file and have each of the value copied to different variables. Please suggest what... (1 Reply)
Discussion started by: souryadipta
1 Replies

7. Shell Programming and Scripting

use of parenthesis() in shell programming

What's the use of parenthesis () in shell programming ? I saw this in one of the posts in this forum : echo $($1) What confounded me was that it evaluated the inner expression and then the outer one, almost like eval. It seemed like it did this in passes. (2 Replies)
Discussion started by: daudiam
2 Replies

8. Shell Programming and Scripting

Parse for errors shell script

All, I have a shell script which parses the /var/adm/messages file for errors every 15 minutes as a cron job. The script runs at 01, 16, 31, and 46 minutes every hour. The problem is if the error is encountered any time during the beginning of hour I can get paged three times. I would like to... (2 Replies)
Discussion started by: bubba112557
2 Replies

9. Shell Programming and Scripting

parse data using sh script

Hi, I am a newbie to unix/shell scripting and i have a question on how to parse a txt file using perl in a sh script. I have a txt file that contains hundreds of lines with data like this.... X, Y, Latitude, Longitude 1, 142, -38.000000, -91.000000, 26.348 2, 142, 60.000000, -90.000000,... (2 Replies)
Discussion started by: moonbaby
2 Replies

10. Shell Programming and Scripting

Help!!! Shell script to parse data file.

I am faced with a :confused: tricky problem to parse a data file ( May not be a tricky problem to the scripting guru's ). Here is what I am faced with. I have a file with multiple rows of data and the rows are not of fixed length. "|" is used as a delimiters for individual columns and each row... (3 Replies)
Discussion started by: yajaykumar
3 Replies
Login or Register to Ask a Question