Sponsored Content
Top Forums Shell Programming and Scripting Problems with awk (fatal error) and paste (two variables into one column-by-column) Post 302922724 by vgbraymond on Tuesday 28th of October 2014 01:56:34 AM
Old 10-28-2014
Quote:
Originally Posted by RudiC
You could try this to get at the (two in your sample file) data columns (unfortunately all zeroes in your sample file); I didn't quite understand what averaging you wanted to achieve, so I leave it up to you. Give it a try:
Code:
awk     '/Direct signal/        {L=1; RCnt++}
         /Cross-talk/           {L=0}
         /Number of/            {NoS=$NF}
         L && / \+ \(/          {SoL=NR; EoL=NR+NoS-1}
         NR<=EoL                {sub (/\)/,_); TM[NR-SoL]=$(NF-1); DT[NR-SoL,RCnt]=$NF/NoS}
         END                    {for (i=0; i<NoS; i++)
                                        {printf "%14.8E", TM[i]
                                         for (j=1; j<=RCnt; j++) printf "\t%14.8E", DT[i,j]
                                         printf "\n"
                                        }
                                }
        ' /tmp/SampleDataFile.pwl.txt
0.00000000E+00  0.00000000E+00  0.00000000E+00
3.00000020E-10  0.00000000E+00  0.00000000E+00
6.00000050E-10  0.00000000E+00  0.00000000E+00
9.00000020E-10  0.00000000E+00  0.00000000E+00
1.20000010E-09  0.00000000E+00  0.00000000E+00
1.50000000E-09  0.00000000E+00  0.00000000E+00
1.80000000E-09  0.00000000E+00  0.00000000E+00
2.10000020E-09  0.00000000E+00  0.00000000E+00
2.40000020E-09  0.00000000E+00  0.00000000E+00
2.70000000E-09  0.00000000E+00  0.00000000E+00
3.00000000E-09  0.00000000E+00  0.00000000E+00
3.30000030E-09  0.00000000E+00  0.00000000E+00
. . .

Hi RudiC,

Thanks for your reply! Your code is far neater than mine. I have to spend some time on understanding it first.

Thanks,
Raymond
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

paste each 10 lines of single column to several column

Hi, I need to paste each 10 lines of single column to several columns. Please, can anyone tell me how to write in awk? Input File: 22 34 36 12 17 19 15 11 89 99 56 38 29 (4 Replies)
Discussion started by: nica
4 Replies

2. Shell Programming and Scripting

for each different entry in column 1 extract maximum values from column 2 in unix/awk

Hello, I have 2 columns (1st column has multiple entries but the corresponding values in the column 2 may be the same or different.) however I want to extract unique values for each entry in column 1 by assigning the max value from column 2 SDF4 -0.211654 SDF4 0.978068 ... (1 Reply)
Discussion started by: Diya123
1 Replies

3. Shell Programming and Scripting

AWK script to create max value of 3rd column, grouping by first column

Hi, I need an awk script (or whatever shell-construct) that would take data like below and get the max value of 3 column, when grouping by the 1st column. clientname,day-of-month,max-users ----------------------------------- client1,20120610,5 client2,20120610,2 client3,20120610,7... (3 Replies)
Discussion started by: ckmehta
3 Replies

4. Shell Programming and Scripting

awk or sed: change the color of a column w/o screwing up column spacing

Hey folks. I wrote a little awk script that summarizes /proc/net/dev info and then pipes it to the nix column command to set up column spacing appropriately. Here's some example output: Iface RxMBytes RxPackets RxErrs RxDrop TxMBytes TxPackets TxErrs TxDrop bond0 9 83830... (3 Replies)
Discussion started by: ryran
3 Replies

5. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

6. UNIX for Dummies Questions & Answers

Paste column from one file as column of

Any shortcuts for doing this? I need to cut the column 4 values from File1 and paste them as column4 values of File2, but only for the (first) same number of lines as File1 . All rows in File1 are contained in File2 in the exact same order, so the cut paste should work. File1 (with header and 3... (4 Replies)
Discussion started by: senhia83
4 Replies

7. Shell Programming and Scripting

awk to Sum columns when other column has duplicates and append one column value to another with Care

Hi Experts, Please bear with me, i need help I am learning AWk and stuck up in one issue. First point : I want to sum up column value for column 7, 9, 11,13 and column15 if rows in column 5 are duplicates.No action to be taken for rows where value in column 5 is unique. Second point : For... (1 Reply)
Discussion started by: as7951
1 Replies

8. Shell Programming and Scripting

awk script to append suffix to column when column has duplicated values

Please help me to get required output for both scenario 1 and scenario 2 and need separate code for both scenario 1 and scenario 2 Scenario 1 i need to do below changes only when column1 is CR and column3 has duplicates rows/values. This inputfile can contain 100 of this duplicated rows of... (1 Reply)
Discussion started by: as7951
1 Replies

9. Shell Programming and Scripting

Need awk or Shell script to compare Column-1 of two different CSV files and print if column-1 matche

Example: I have files in below format file 1: zxc,133,joe@example.com cst,222,xyz@example1.com File 2 Contains: hxd hcd jws zxc cst File 1 has 50000 lines and file 2 has around 30000 lines : Expected Output has to be : hxd hcd jws (5 Replies)
Discussion started by: TestPractice
5 Replies

10. UNIX for Beginners Questions & Answers

How to copy a column of multiple files and paste into new excel file (next to column)?

I have data of an excel files as given below, file1 org1_1 1 1 2.5 100 org1_2 1 2 5.5 98 org1_3 1 3 7.2 88 file2 org2_1 1 1 2.5 100 org2_2 1 2 5.5 56 org2_3 1 3 7.2 70 I have multiple excel files as above shown. I have to copy column 1, column 4 and paste into a new excel file as... (26 Replies)
Discussion started by: dineshkumarsrk
26 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 03:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy