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
-2
votes
1 answer

awk - show difference between two fields

I have this: bar foobar 111 random111 I want to define $2 so that when compared to $1, it should contain only the differences (non-matching characters): bar foo 111 random
one-liner
  • 791
  • 1
  • 9
  • 19
-2
votes
2 answers

Selecting date only column in awk

I have this piece of code: { if ($4 ~search) { match ($4, /([0-9]{2}\/([a-zA-z]{3})\/([0-9]{4}))/, dates) print dates[1] "\t" dates[2] "\t" dates[3] } } and when it is run it produces this:…
user2160949
  • 131
  • 2
  • 9
-2
votes
2 answers

gawk command in matching data

The original logfile sample: "GET …
user1536782
  • 97
  • 1
  • 2
  • 12
-2
votes
3 answers

break text file into multiple text files

I have tried my best to understand a very similar StackOverflow question, but I cannot for the life of me make either the proposed gawk or split solutions to work in my case. I have a large text file consisting of 288 proposals, each of which is…
John Laudun
  • 407
  • 1
  • 9
  • 19
-3
votes
2 answers

modifying working regex to work with g/awk

Ive a working regex pattern: ^\s+$\n^([ \t]+)Summary.*(?:\n\1[ \t]*\S.*)+ Designed to match an entire paragraph that starts with the word "Summary", as per this question. I am now seeking to have this work with gawk, e.g. gawk '/^\s+$\n^([…
haz
  • 740
  • 1
  • 11
  • 20
-3
votes
2 answers

I have a Tab separated file in Unix which has data issue

I have to make sure each line has 4 columns, but the input data is quite a mess: The first line is header. The second line is valid as it has 4 columns. The third is also valid (it's ok if the description field is null) ID field and "god bless…
dragon007
  • 1
  • 2
-3
votes
2 answers

Count number of lines in a Fixed length file with a specific character in 12th Position in each line

I have a Fixed length file, it is a large file with millions of records. The length of the record in each line is 19. In each line 12th character corresponds to a particular status for which I need to get the count of each status in the file. Eg: …
normalindon1
  • 55
  • 1
  • 5
-3
votes
1 answer

Using awk to interpolate data column based in a data file with date and time

The following file has multiple columns with date, time and incomplete data set as shown using a simple file # Matrix.txt 13.09.2016:23:44:10;;4.0 13.09.2016:23:44:20;10.0; 13.09.2016:23:44:30;; 13.09.2016:23:44:40;30.0;7.0 How can I do an linear…
-3
votes
3 answers

Determining whether a given column in all rows of a file meets criteria

Let's say i have a file with below content. ok yes bad ok yes good ok yes bad ok yes good ok yes bad ok yes good I need to write a shell script or awk program to search the whole 3rd column and if the whole…
suru1432002
  • 143
  • 2
  • 8
-3
votes
1 answer

filter out data from file on the basis of other in awk

I have a big file having 50s columns and 100K of rows delimited by |. Now $2(col 2) has multiple type of $1(col 1) value which means col 2 will be repeated. So I have sorted the file. I need now to extract/filter the result file on the basis of…
appi
  • 75
  • 1
  • 3
  • 10
-3
votes
1 answer

Processing CSV file in smartest way

I have one CSV file: ID;CREATED_AT;CITY 42;2015-05-25 14:27:29;Delhi 33;2015-05-11 09:07:37;London 453;2015-05-22 14:27:29;Delhi 33;2015-05-12 09:07:37;Kolkata 453;2015-05-24 14:27:29;Bangalore 42;2015-05-26 14:27:29;Delhi 453;2015-05-21…
user1735076
  • 3,225
  • 7
  • 19
  • 16
-3
votes
2 answers

Remove a string when a condition is met

I have a tab-separated text, within the text is a string that appears on several occasions and I need to remove it when accompanied by other strings. A B C D E F G H I J string string string car29 "" "" "" "" …
Polucho
  • 23
  • 5
-3
votes
1 answer

optional variable passing in awk & sort

I want to use optional variable passing in awk suppose i have two file and i want to print the match/ unmatch values taking one or multiple column values as a identifier key. file1 1 || 2 || 3 2 || 3 || 2 file 2 1 || 3 || 3 2 || 3 || 1 here is…
bongboy
  • 147
  • 1
  • 15
-3
votes
1 answer

how to change a dynamic pattern in awk?

the data is something like "1||2""3""2||3""5""4||3""6""43""4||4||3""4||3", 43 ,"4||3""43""3||4||4||3" i've tried this myself BEGIN { FPAT = "(\"[^\"]+\")|([ ])" } { print "NF = ", NF for (i = 1; i <= NF; i++) { printf("$%d =…
bongboy
  • 147
  • 1
  • 15
-4
votes
2 answers

grep -Ff producing invalid output

I'm using code - grep -Ff list.txt C:/data/*.txt > found.txt but it keeps outputting invalid responses, lines don't contain the emails i input.. list.txt contains…
jake reading
  • 79
  • 1
  • 1
  • 5
1 2 3
65
66