Sponsored Content
Full Discussion: UNIX awk help
Top Forums UNIX for Dummies Questions & Answers UNIX awk help Post 302137938 by royayala on Thursday 27th of September 2007 05:49:08 PM
Old 09-27-2007
UNIX awk help

I am new to UNIX and I need a sample awk or sed program to solve the following problem.

I have a file with the following format. The file is comma delimited. Each record has header information followed by looping detailed information. In addition the detailed information will vary based on a value found in the header information. For example if the header information has a value of 48 then the detail will have 48 sets of detail information. A set of detailed information is a set of 3 fields. The other value is 24, so the detail will either have 48 sets or 24 sets of detail.

What I want to do is replace the delimiter after the value 48 or 24 and around each triplete of information. I highligted the areas in bold where I want to change the comma to a semi colon.

Sample of current record:
MEPMD01,19970819,Sensus,SDGE,SDGE,,200705221435,1888961,OK,E,KWH,1,00000015,48,200705210715,R 00 40,2.0000,200705210730,R 00 40,1.0000,200705210745,R 00 40,2.0000,200705210800,R 00 40,1.0000,200705210815,R 00 40,2.0000,200705210830,R 00 40,2.0000,200705210845,R 00 40,1.0000,200705210900,R 00 40,2.0000,200705210915,R 00 40,2.0000,200705210930,R 00 40,1.0000,200705210945,R 00 40,2.0000,200705211000,R 00 40,1.0000,200705211015,R 00 40,2.0000,200705211030,R 00 40,2.0000,200705211045,R 00 40,1.0000,200705211100,R 00 40,2.0000,200705211115,R 00 40,2.0000,200705211130,R 00 40,1.0000,200705211145,R 00 40,2.0000,200705211200,R 00 40,1.0000,200705211215,R 00 40,2.0000,200705211230,R 00 40,2.0000,200705211245,R 00 40,1.0000,200705211300,R 00 40,2.0000,200705211315,R 00 40,2.0000,200705211330,R 00 40,1.0000,200705211345,R 00 40,2.0000,200705211400,R 00 40,1.0000,200705211415,R 00 40,1.0000,200705211430,R 00 40,2.0000,200705211445,R 00 40,1.0000,200705211500,R 00 40,1.0000,200705211515,R 00 40,1.0000,200705211530,R 00 40,1.0000,200705211545,R 00 40,1.0000,200705211600,R 00 40,1.0000,200705211615,R 00 40,1.0000,200705211630,R 00 40,1.0000,200705211645,R 00 40,1.0000,200705211700,R 00 40,1.0000,200705211715,R 00 40,1.0000,200705211730,R 00 40,1.0000,200705211745,R 00 40,1.0000,200705211800,R 00 40,1.0000,200705211815,R 00 40,1.0000,200705211830,R 00 40,1.0000,200705211845,R 00 40,1.0000,200705211900,R 00 40,1.0000

Roy Ayala
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix To Awk

How do I alias the FILE name into awk? gawk -f awk_script FILE or FILE | gawk awk_script for FILE in `find ./* -prune -type f -newer ./TIMEFILE` do # Need to have the actual FILE name ran thru an awk script done (1 Reply)
Discussion started by: goodmis
1 Replies

2. Shell Programming and Scripting

unix awk scripting

Hi can anyone pls help me out in knowing how a array of elements which are fetched from database is passed to the awk program. Something like this #!/bin/sh AMT=`sqlplus -s usrname/pswd <<EOD set pagesize 0 feedback off verify off heading off echo on select amount from... (11 Replies)
Discussion started by: shaik
11 Replies

3. UNIX for Dummies Questions & Answers

Clock in Unix using awk

Hey everyone! Can someone help me, i need to make a program using awk, that displays the current time (hh/mm/ss), i would really apreciate it! Thanks! Alex. (4 Replies)
Discussion started by: alex_omul
4 Replies

4. Shell Programming and Scripting

need help with UNIX and awk

Hi, I am working on a script where i am fetching a word from a parameter file and using it as output file name . here is the part of parameter file contents : it basically contains SQL statements. Select 'SSFNRTP' as TABLE_NAME,UCSTDT,CVOFIDKEY from (Select 'cofvof_interface' as... (2 Replies)
Discussion started by: manmeet
2 Replies

5. UNIX for Dummies Questions & Answers

AWK Help (New to UNIX)

Write a script to calculate the average score and assign a letter grade for each student, also compute the average score for every test (the source data is in the file “grades”). Output all students' name, scores, and grades in descending order of the average score. Note: please save the output to... (17 Replies)
Discussion started by: dsptl
17 Replies

6. Shell Programming and Scripting

Help in unix in awk

Hi, I have a file as given below $cat int_check 239|adf123@yahoo.com|999e 23e|get@rediff.com|987 233|get@rediff.com|987 I am running the command as given to find whether field 1 and 3 have proper integer values or not. awk -F'|' 'int($1)!=$1 || int($3)!=$3' int_check... (7 Replies)
Discussion started by: ashwin3086
7 Replies

7. UNIX for Advanced & Expert Users

awk sub command in Unix

Hi, I am new to unix shell script and I have some trouble on the awk sub I would like to pick the Date "July 10 2012" into $corr_date by using sub() function, but it is not successful. The inputted text file: pic.*.txt July 10 2012 20:30:50 , 1234567.jpg July 10 2012 20:30:52 , 5648978.jpg... (1 Reply)
Discussion started by: meroko
1 Replies

8. AIX

awk UNIX

friends because I get this error when calling awk awk: 0602-546 Can not find or open file estdistica.awk. (10 Replies)
Discussion started by: tricampeon81
10 Replies

9. UNIX for Dummies Questions & Answers

UNIX inquiry for 'awk'

Hello Everyone, May I ask for your help regarding one of the UNIX command “awk”. So I executed a script and the output looks like this (see below): output.txt CONTRACTNAME ... (3 Replies)
Discussion started by: steven_huskie
3 Replies

10. How to Post in the The UNIX and Linux Forums

Help me in awk or sed in UNIX

I have a fixed length file that looks like a@ a00 a00000 a00 a000000 a00 a0000 a0000 a00000000 a01 a@ a1 a2 a11 a22 a12 a13 a44 a45 a54 a65 a76 a77 a@ a1 a3 a6 a7 a9 a8 a2 a7 a8 a8 a9 a0 b@ b00 b00000 b00... (1 Reply)
Discussion started by: RJG
1 Replies
OUTPUT(5)							File Formats Manual							 OUTPUT(5)

NAME
output - output data file formats DESCRIPTION
This manual page describes the output formats of the files created by the Yagi-Uda project's output program. The files are ASCII file, so can be analysed with any graph plotting program. Example of a .dat File Below is a typical .dat file, for a 4ele 144-146MHz beam, optimised for a huge (and useless) FB. # Driven=1 parasitic=3 total-elements=4 design=145.000MHz # Checked from 144.000MHz to 146.000MHz. f(MHz) E(deg) H(deg) R jX VSWR Gain(dBi) FB(dB) SideLobes(dB) 144.000 54.7 71.5 44.47 -2.35 1.136 9.386 21.944 16.650 144.500 54.0 70.1 41.34 -0.75 1.210 9.553 27.244 17.153 145.000 53.2 68.4 37.55 1.61 1.335 9.742 103.055 17.777 145.500 52.3 66.6 33.26 5.00 1.530 9.947 25.734 18.547 146.000 51.3 64.6 28.77 9.63 1.832 10.149 18.919 18.919 What is what in the .dat file The f(MHz) column is the frequency (MHz) at which the data is evaluated at. The E(deg) column is the approximate 3dB E-plane bandwidth calculated to the nearest 0.1 degree. The H(deg) column is the approximate 3dB H-plane bandwidth calculated to the nearest 0.1 degree. The (R) column is the input resistance in Ohms. The (jX) column is the input reactance in Ohms. The (VSWR) column is the input VSWR, usually refered to a 50 Ohm input, but this may be changed. The Gain (dBi) column is the gain at theta=90 degrees, which is the forward direction of the beam. It is possible that a higher gain occurs at other than 90 degrees, but this is not taken into account. The antenna is seriously at fault if this occurs. The FB(dB) column is the front to back ratio in dB. The Sidelobes(dB) column is the minimum level in dB down from the peak gain of any sidelobe. This is not calculated unless the '-c' option is used, and then only on some optimisation techniques. Example of a .gai File The following is a small section of the .gai file. f(MHz) theta gain-E(dBi) G(E)-peak phi gain-H(dBi) G(H)-peak 144.0000 -90.0000 -12.5584 -21.9444 -180.0000 -12.5584 -21.9444 144.0000 -45.0000 -7.3507 -16.7367 -135.0000 -3.5971 -12.9830 144.0000 0.0000 -999.0000 -1008.3860 -90.0000 -0.9010 -10.2870 144.0000 45.0000 0.1848 -9.2012 -45.0000 4.0261 -5.3599 144.0000 90.0000 9.3860 0.0000 0.0000 9.3860 0.0000 144.0000 135.0000 0.1848 -9.2012 45.0000 4.0261 -5.3599 144.0000 180.0000 -999.0000 -1008.3860 90.0000 -0.9010 -10.2870 144.0000 225.0000 -7.3507 -16.7367 135.0000 -3.5971 -12.9830 144.0000 270.0000 -12.5584 -21.9444 180.0000 -12.5584 -21.9444 What is what in the .gai file The f(MHz) column is the frequency in MHz. The theta column is the angle theta, for which the next two columns refer. The gain-E(dBi) is the gain at theta, relative to an isotropic radiator. This is the E-plane gain. Hence at the peak (theta), this gives the peak forward gain. The G(E)-peak is the gain at theta, relative to the peak gain. Hence at the peak (theta=90 degrees), this is zero. The phi column has nothing to do with the previous 3 columns. It is the angle for which the next two columns refer. The gain-H(dBi) is the gain at phi, relative to an isotropic radiator. This is the H-plane gain. Hence at the peak (phi=0), this gives the peak forward gain. The G(H)-peak is the gain at phi, relative to the peak gain. Hence at the peak (phi=0 degrees), this is zero. Example of a .up File The .up file list the improvements made by optimise to an antenna design. Starting from the original design, the file is appended each time a new better design is found. Here is an example, where the final line is the performance of the 4ele beam with the .dat file shown ear- lier. 1 7.57dBi, 16.93dB F/B, Z=(31.77-56.34j) Ohms, VSWR=3.95, SL=16.95 dB 84 7.58dBi, 16.93dB F/B, Z=(31.78-56.32j) Ohms, VSWR=3.95, SL=16.95 dB 623 7.58dBi, 16.93dB F/B, Z=(31.78-56.28j) Ohms, VSWR=3.95, SL=16.95 dB 89345 9.74dBi, 103.06dB F/B, Z=(37.55 +1.61j) Ohms, VSWR=1.33, SL=17.78 dB What is what in the .up file The first column is an integer specifying the iteration. The other columns, going from left to right are gain(dBi), FB, input impedance, VSWR and level of the most significant sidelobe, in dB down on the peak gain. SEE ALS0 yagi(1), output(1), input(1), optimise(1), first(1) and yagi(5). AUTHORS
Dr. David Kirkby G8WRB (david.kirkby@onetel.net), with help with converting to DOS from Dr. Joe Mack NA3T (mack@fcrfv2.ncifcrf.gov). Version 1.16 24th October 2000 OUTPUT(5)
All times are GMT -4. The time now is 06:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy