RegeX to parse data from a txt file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting RegeX to parse data from a txt file
# 1  
Old 06-26-2012
RegeX to parse data from a txt file

Hi all the experts out there,
I am totally new to perl and I was given an assignment by using Perl to find the 2nd element of each line in each curly bracket which made up of 5 elements.

Expected result should like this:

Type: VCC Pin_name: AK32,AL32,AH21,.....
Type: NC Pin_name: AW34,AW35,.....


Any help is appreciated.

Code:
***Jojo*** VCC={NA AK32 {NA} NA  NA} {NA AL32 {NA} NA  NA} {NA AH21 {NA} NA  NA} {NA AJ21 {NA} NA  NA} 
***Jojo*** NC={NA AW34 {NA} NA  NA} {NA AW35 {NA} NA  NA} {NA V27 {NA} NA  NA} {NA AF20 {NA} NA  NA} {NA AW5 {NA} NA  NA} {NA AW6 {NA} NA  NA} {NA H6 {NA} NA  NA} {NA N22 {NA} NA  NA}
***Jojo*** GND={NA T12 {NA} NA  NA} {NA AC14 {NA} NA  NA} {NA A35 {NA} NA  NA} {NA A37 {NA} NA  NA} {NA A38 {NA} NA  NA} {NA AA34 {NA} NA  NA} {NA AA35 {NA} NA  NA} {NA AA38 {NA} NA  NA} {NA AA39 {NA} NA  NA} {NA AB32 {NA} NA  NA} {NA AB36 {NA} NA  NA} {NA AB37 {NA} NA  NA} {NA AC34 {NA} NA  NA} {NA AC35 {NA} NA  NA} {NA AC38 {NA} NA  NA} {NA AC39 {NA} NA  NA} {NA AD31 {NA} NA  NA} {NA AD33 {NA} NA  NA} {NA AD36 {NA} NA  NA} {NA AD37 {NA} NA  NA} {NA AE34 {NA} NA  NA} {NA AE35 {NA} NA  NA} {NA AE38 {NA} NA  NA} {NA AE39 {NA} NA  NA} {NA AF32 {NA} NA  NA} {NA AF36 {NA} NA  NA} {NA AF37 {NA} NA  NA} {NA AG34 {NA} NA  NA} {NA AG35 {NA} NA  NA} {NA AG38 {NA} NA  NA} {NA AG39 {NA} NA  NA} {NA AH31 {NA} NA  NA} {NA AH33 {NA} NA  NA} {NA AH36 {NA} NA  NA} {NA AH37 {NA} NA  NA} {NA AJ34 {NA} NA  NA}  NA} {NA AT35 {NA} NA  NA} NA  NA}L35 {NA} NA  NA} {NA L38 {NA} NA  NA} {NA L39 {NA} NA  NA} {NA M31 {NA} NA  NA} {NA M36 {NA} NA  NA} {NA M37 {NA} NA  NA} {NA N34 {NA} NA  NA} {NA N35 {NA} NA  NA} {NA N38 {NA} NA  NA}


Last edited by killbanne; 06-27-2012 at 12:29 AM..
# 2  
Old 06-27-2012
PHP Code:
bumped 

Last edited by killbanne; 06-27-2012 at 12:25 AM..
# 3  
Old 06-27-2012
Try like...
Code:
 sed 's/\NA//g' test.txt | tr -d '}{' <

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse through a txt file PERL scripting

Below is a perl code I am trying. #!/usr/bin/perl #use strict; use warnings qw/ all FATAL /; use constant ENV_FILE => '/apps/env_data.txt'; $uenv = $ARGV; my $input = $uenv; open my $fh, '<', ENV_FILE or die sprintf qq{Unable to open "%s" for input: $!}, ENV_FILE; ... (2 Replies)
Discussion started by: Tuxidow
2 Replies

2. Shell Programming and Scripting

Data extraction from .txt file

Hey all, i´ve got the following problem: i´m aquiring data with an instrument and i get data in a .txt file. This is how the txt file looks like: Report of AU program poptau F1P=-49.986ppm F2P=-110.014ppm Target directory for serfile: D:/data/Spect500/nmr/Thoma/882 Linear... (17 Replies)
Discussion started by: expikx
17 Replies

3. Shell Programming and Scripting

create txt file form data file and add some line on it

Hi Guys, I have file A.txt File A Data AK1521 AK2536 AK3164 I want create text file of all data above and write some data on each file. want Output on below folder /home/kka/out AK1521.txt Hi Welocme (3 Replies)
Discussion started by: asavaliya
3 Replies

4. 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

5. Shell Programming and Scripting

Regex to Parse data

Experts and Informed folks, Need some help here in parsing the log file. 1389675 Opera_ShirtCatalog INSERT INTO Opera_ShirtCatalog(COL1, COL2) VALUES (1, 'TEST1'), (2,'TEST2'); 1389685 Opera_ShirtCatlog_Wom INSERT INTO Opera_ShirtCatlog_Wom(col1, col2, col3) VALUES (9,'Siz12, FormFit',... (12 Replies)
Discussion started by: ManoharMa
12 Replies

6. UNIX for Dummies Questions & Answers

How to parse the specific data from the file

Hi, I need to parse this data FastEthernet0/9,|FastEthernet0/10,|FastEthernet0/11,FastEthernet0/13|, FastEthernet0/12,FastEthernet0/24 . and get only the value like e.g 0/24,0/11. how to do this in shell script. Thanks in Advance. (2 Replies)
Discussion started by: MuthuAlagappan
2 Replies

7. 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

8. Shell Programming and Scripting

unix script to takes the old data from a TXT file and compress them into new file

Hi, I am looking for the unix script which can takes the 2 month old data from a TXT file (there is one txt file in whiche messages are appended on daily basis) and compress them into new file.Please halp me out. (2 Replies)
Discussion started by: vpandey
2 Replies

9. Shell Programming and Scripting

Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies

10. UNIX for Advanced & Expert Users

get data from .txt file

Hi I have a file diskspace.txt the data in that file is asFilesystem kbytes used avail %used Mounted on /dev/vg06/lvol1 18870272 12099836 6673336 64% /dist know i am writing a script to get the above bold data and that data need to be used as a input. any idea... (4 Replies)
Discussion started by: gkrishnag
4 Replies
Login or Register to Ask a Question