Parse file using awk and work in awk output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parse file using awk and work in awk output
# 1  
Old 02-13-2010
Tools Parse file using awk and work in awk output

hi guys,
i want to parse a file using public function, the file contain raw data in the below format i want to get the output like this to load it to Oracle DB

Code:
MARWA1,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00
MARWA2,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00

this the file raw format:

Code:
Number of Available TCHs (1,16) 26/01/2010 01:00:00+00:00 bts {26 18 0} {bts:26-18_MARWA1} 90 BSS:26/SCANBTS:0 60 1 3 0 0 0 0 0.00 22 22 22.00
Number of Available TCHs (1,16) 26/01/2010 01:00:00+00:00 bts {26 18 1} {bts:26-18_MARWA2} 90 BSS:26/SCANBTS:0 60 1 3 0 0 0 0 0.00 22 22 22.00

I used awk to parse the out put but I couldn't get them all in one line,
Code:
cat $FileToPars| grep "Number of Available TCHs" | awk -F_ '{print $2}'


how to trim the "}" letter to get "MARWA1" ?




Last edited by Franklin52; 02-13-2010 at 11:25 AM.. Reason: Please use code tags!!
# 2  
Old 02-13-2010
Code:
sub("}","",$2)

# 3  
Old 02-13-2010
# cat $FileToPars| grep "Mean number of busy TCHs" | awk -F_ '{ [print sub("}","",$2)}'
awk: syntax error near line 1
# 4  
Old 02-13-2010
Code:
awk -F'[_ }\/]' '/Number of Available TCHs/{print $16,$19,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31}' OFS="," infile

# 5  
Old 02-13-2010
no change it gives just comas ,,,,,, still not wroks......Smilie
# 6  
Old 02-13-2010
Quote:
Originally Posted by dagigg
# cat $FileToPars| grep "Mean number of busy TCHs" | awk -F_ '{ [print sub("}","",$2)}'
awk: syntax error near line 1
Code:
awk -F_ '{ sub("}","",$2); print $2 } '

# 7  
Old 02-13-2010
I did it in a hard way.... so far it is works , but not public function
Code:
awk -F_ '/Number of Available TCHs/{print $2}' BR90_26.20100126000000+0000.20100126010000+0000-000.ASCII | awk -F} '{print $1 $2}' | awk '{print $1 " BSS:26 " " " $5 " " $6 " " $7 " "$8}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Parse output and then compare column wise with awk

Hello, I am trying to write a script to parse the output of data and then alert based on certain conditions This is the output of my script (STRING) Name = Joe (FLOAT64) BMI = 34 (FLOAT64) Weight = 156 (STRING) Name = Sam (FLOAT64) BMI = 32 (FLOAT64) Weight = 180 and so on it repeats... (4 Replies)
Discussion started by: sidnow
4 Replies

2. Shell Programming and Scripting

How to parse this file using awk and output in CSV format?

My source file looks like this: Cust-Number = "101" Cust-Name="Joe" Cust-Town="London" Cust-hobby="tennis" Cust-purchase="200" Cust-Number = "102" Cust-Name="Mary" Cust-Town="Newyork" Cust-hobby="reading" Cust-purchase="125" Now I want to parse this file (leaving out hobby) and... (10 Replies)
Discussion started by: Balav
10 Replies

3. Shell Programming and Scripting

awk to parse html file

Is it possible in awk to parse a webpage (EDAR Gene Sequencing - Genetic Testing Company | The DNA Diagnostic Experts | GeneDx), the source code is attached. <title> EDAR Gene Sequencing <dt>Test Code:</dt> <dd>156 </dd> <dt>Turnaround Time:</dt> <dd>6-8 weeks </dd> ... (4 Replies)
Discussion started by: cmccabe
4 Replies

4. Shell Programming and Scripting

Using awk to Parse File

Hi all, I have a file that contains a good hundred of these job definitions below: Job Name Last Start Last End ST Run Pri/Xit ________________________________________________________________ ____________________... (7 Replies)
Discussion started by: atticuss
7 Replies

5. Shell Programming and Scripting

awk to parse df output

Output of the below code includes unmatched date.Please correct it df -k|awk '$4>50 {print $1, "\t"$4,"\t" $7}' It gives output less than 50% also. (5 Replies)
Discussion started by: vinil
5 Replies

6. Shell Programming and Scripting

awk to parse jil output

Hi , I have a jil file which i am trying to parse and print the job name and the condition corresponding to it. Below is the input file /* -------------------- testjob1 -------------------- */ insert_job: testjob1 job_type: c machine: unix owner: chidori condition: s(joba) and... (9 Replies)
Discussion started by: chidori
9 Replies

7. Shell Programming and Scripting

Parse a file using awk

Hi Experts, I am trying to parse the following file; FILEA a|b|c|c|c|c a|b|d|d|d|d e|f|a|a|a|a e|f|b|b|b|boutput expected: a<TAB>b <TAB><TAB>c<TAB>c<TAB>c<TAB>c<TAB> <TAB><TAB>d<TAB>d<TAB>d<TAB>d<TAB> e<TAB>f <TAB><TAB>a<TAB>a<TAB>a<TAB>a<TAB> <TAB><TAB>b<TAB>b<TAB>b<TAB>b<TAB>*... (7 Replies)
Discussion started by: rajangupta2387
7 Replies

8. Shell Programming and Scripting

Parse a file with awk?

Hi guys (and gals). I need some help. I'm running an IVR purely on Asterisk where I capture the DTMFs. After pulsing each DTMF I have Asterisk write to a file with whatever was dialed (mostly used for record-keeping) and at the end of the survey I write all variables in a single line to a... (2 Replies)
Discussion started by: tulf210
2 Replies

9. Shell Programming and Scripting

AWK - Parse a big file

INPUT SAMPLE Symmetrix ID : 000192601507 Masking View Name : TS00P22_13E_1 Last updated at : 05:10:18 AM on Tue Mar 22,2011 Initiator Group Name : 10000000c960b9cd Host Initiators { WWN : 10000000c960b9cd } Port Group Name :... (8 Replies)
Discussion started by: greycells
8 Replies

10. Shell Programming and Scripting

To parse through the file and print output using awk or sed script

suppose if u have a file like that Hen ABCCSGSGSGJJJJK 15 Cock ABCCSGGGSGIJJJL 15 * * * * * * : * * * . * * * : Hen CFCDFCSDFCDERTF 30 Cock CHCDFCSDHCDEGFI 30 * . * * * * * * * : * * :* : : . The output shud be where there is : and . It shud... (4 Replies)
Discussion started by: cdfd123
4 Replies
Login or Register to Ask a Question