Questions tagged [gawk]

gawk (short for GNU awk) is a free implementation of awk with manifold useful extensions.

gawk (short for GNU awk) is a free implementation of awk with manifold useful extensions.

AWK is an interpreted programming language designed for text processing and typically used as a data extraction and reporting tool. It is a standard feature of most Unix-like operating systems.

Source: Wikipedia

See also .

Reference

981 questions
-1
votes
2 answers

Issue in handling pipe delimited flat files,each field within double quotes. What can be a solution here

I have to handle pipe delimited flat files, in which each field comes within double quotes. sample data: "1193919"|"false"|""|"Mr. Andrew Christopher Alman"|""|""|"Mr." I have written many gawk commands in my scripts. Now the issue…
DPR
  • 25
  • 6
-1
votes
1 answer

Awk : does not report error for 202D, 203B etc, it accepts one alpha character

I need to find out whether a field in a pipe delimited file is a numeric or not. I need to report if the field is not a numeric field, ignore if it is numeric and also ignore if it is null. I have other computations. I wrote this code: gawk -v…
DPR
  • 25
  • 6
-1
votes
3 answers

How to remove leading and trailing " , remove leading and trailing spaces from each row each field in ksh

I have many functions in ksh scripts(which uses gawk a lot) which does many computations on files. Files are pipe delemited. But now my source files changed. Now each field in the file comes within double quotes as below. Also, I have to trim the…
DPR
  • 25
  • 6
-1
votes
2 answers

Short way to apply gensub to all fields in awk

I have this awk command which reads single line xml with different fields. I had to use gensub on all fields one by one. suppose this is my xml file 123 The output i want is 1--2--3 Also i want to…
Karl
  • 2,903
  • 5
  • 27
  • 43
-1
votes
3 answers

Gawk Line removal, Splitter is :

Is it possible to move certain columns from one .txt file into another .txt file? I have a .txt that contains: USERID:ORDER#:IP:PHONE:ADDRESS:POSTCODE USERID:ORDER#:IP:PHONE:ADDRESS:POSTCODE With gawk I want to extract ADDRESS & POSTCODE columns…
wolf pkrs
  • 37
  • 1
  • 2
  • 8
-1
votes
2 answers

awk. find unique values count for every element in other column

Find count of a unique values in second column for every unique value in column one using awk associative arrays?? a,x a,y a,z a,w b,x b,y a,x b,x o/p should be a,4 b,2
-1
votes
1 answer

Issue with AWK array length?

I have a tab separated matrix (say filename). If I do: head -1 filename | awk -F "\t" '{i=0;med=0;for(i=2;i<=NF;i++) array[i]=$i;asort(array);print length(array)}' followed by: head -2 filename | tail -1 | awk -F "\t" '{i=0;med=0;for(i=2;i<=NF;i++)…
-1
votes
2 answers

Awk program to take file name as argument and process commands taking each line of that file

I have a log file containing information of an object. I need script in AWK My log will be like this: ObjectA copy time 2ms ObjectA ID is 23467sdfs3453AAAA ObjectB copy time 7ms Objectc run time 23ms ObjectA process time 3ms ObjectA run time…
RajN
  • 3
  • 4
-1
votes
2 answers

Compare and print unmatched string in unix

I have file like 123|3a|3b 747|3a|3b|3c|3d 636|3c|3b Output : 123 -3c 3d 636 -3a 3d It should compare 3a,3b,3c,3d and show the missing one . I tried using awk '/3a/3b/3c/3d' file.txt but not able to figure out how to compare single string.
-1
votes
1 answer

In bash, do summation of the same column over multiple files

I have 20 files, with each file containing 19 columns and 3000 rows. Now I want to sum over file 1~4, by keep the first column intact (first column are the same over all files), but sum column 2 to 19 over this four files. i.e. sum column 2,3,...,19…
Lei Zhang
  • 103
  • 1
  • 2
  • 7
-1
votes
1 answer

AWK - if and printf, before or within

I have the following printf printf ("%-6s\t%6.3f\n",msg,sum[msg]/count[msg]) the arrays to this are as follows: sum[$2] += $3 count[$2]++ $2 = test1 $3 = 0 - 9 on different lines at random I am to do a if statement to say if either sum[msg] or…
glly
  • 107
  • 7
-1
votes
1 answer

Find min values in field 2 by looping through certain number of records using AWK

I have three fields in dataset file. field 1 acts as id field 2 is used to compare the min field 3 is boolean either 0 or 1. I need to find the min value in field 2 but with respect to field 1. that is, consider below dataset. dataset 1 0.432 0 1…
Murlidhar Fichadia
  • 2,589
  • 6
  • 43
  • 93
-1
votes
1 answer

Remove records with same cross product values in AWK

When I do cross product of records in file.txt > file2.txt using command : join file1.txt{,} -j999 > file2.txt I get each record in file1.txt with all the records in file1.txt such as: sample dataset r1 r2 r3 I get r1 r1 r1 r2 r1 r3 r2 r1 r2 r2 r2…
Murlidhar Fichadia
  • 2,589
  • 6
  • 43
  • 93
-1
votes
1 answer

Cross product of records in AWK using Joins

I have a dataset with 1994 records with 13 fields. I am trying to get the cross product of the dataset below: Dataset c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 1 2 5 6 7 3 1 8 5 9 7 3 4 2 4 . . . . . . . . . . . 3…
Murlidhar Fichadia
  • 2,589
  • 6
  • 43
  • 93
-1
votes
2 answers

Compare values of each records in field 1 to find min and max values AWK

I am new to text preprocessing and AWK language. I am trying to loop through each record in a given field(field1) and find the max and min of values and store it in a variable. Algorithm : 1) Set Min = 0 and Max = 0 2) Loop through $1(field 1) 3)…
Murlidhar Fichadia
  • 2,589
  • 6
  • 43
  • 93