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
2 answers

Return strings within parameters sed/grep/awk/gawk

Need some help to return all data in a log file within 2 specific delimiters. We usually have logs like the one below: 2018-04-17 03:59:29,243 TRACE [xml] This is just a test. 2018-04-17 13:22:24,230 INFO [properties] I believe this is another…
TerminatorX
  • 307
  • 3
  • 13
2
votes
3 answers

How can I use awk to insert something in the middle of the word?

I have an input: This is a test And I want to insert some letters in the middle of the word, like: This is a teSOMETHINGst I know I can define the needed word by $i, but how can I modify the word that way? I'm trying to do it like that: { i=4…
ans
  • 378
  • 1
  • 5
  • 18
2
votes
2 answers

uniq -c is not working with awk?

I have a log file with multiple data i want to filter on DHCPREQUEST IP from that file and I want to count how many time a IP request for that service content in log file is like this :- Mar 22 11:20:34 DHCP-IP dhcp: DHCPREQUEST for 10.1.1.1 from…
Vijay
  • 197
  • 10
2
votes
3 answers

Script to update xml value

I am trying to do update on xml file based on condition using AWK Script. Could anyone assist me on this? students.xml 1 A 75
Dhanabalan
  • 572
  • 5
  • 19
2
votes
1 answer

GNU awk, FPAT and trouble with a duplicating FS

I have a file: $ cat file 1,,"3.1,3.2",4,5 and because of the quotes I'm using FPAT = "([^,]*)|(\"[^\"]+\")") instead of just FS=",". I'm trying to replace a field, lets say $4, with another value: $ gawk 'BEGIN{FPAT="([^,]*)|(\"[^\"]+\")";…
James Brown
  • 36,089
  • 7
  • 43
  • 59
2
votes
3 answers

How do I append the occurrence of a field using awk?

I am trying to append a number to a record that indicates how many times a particular value has occurred in a particular column within a file. For example, let's say my file looks like…
gaspero1
  • 129
  • 8
2
votes
4 answers

Delete specific columns from csv file maintaining same structure on output

I would like to delete column 3 and keep the same structure on output file. input file 12,10,10,10 10,1 12,23 1,45,6,7 11 2,33,45,1,2 1,2,34,5,6 I tried awk -F, '!($3="")' file | awk -v OFS=','…
OXXO
  • 724
  • 5
  • 12
2
votes
2 answers

awk - Compare columns from two files and replace text in first file

I have two files. The first has 1 column and the second has 3 columns. I want to compare first columns of both files. If there is a coincidence, replace column 2 and 3 for specific values; if not, print the same line. File 1: $ cat…
Nicole C
  • 35
  • 4
2
votes
1 answer

print only the pattern in the whole line using grep

As i know to print only the pattern using command grep -o. i have a file like this: Job <472971> Job Name User Project Status Queue Interactive pseudo-terminal shell mode Submitted from host…
Lucil120
  • 63
  • 5
2
votes
1 answer

How to check the type of an awk variable?

The Beta release of gawk 4.2.0, available in http://www.skeeve.com/gawk/gawk-4.1.65.tar.gz is a major release, with many significant new features. I previously asked about What is the behaviour of FS = " " in GNU Awk 4.2?, and now I noticed the…
fedorqui
  • 275,237
  • 103
  • 548
  • 598
2
votes
1 answer

What is the behaviour of FS = " " in GNU Awk 4.2?

The first week of October, Arnold Robbins announced Beta release of gawk 4.2.0 now available in the GNU-announce, bug-gawk and comp.lang.awk mailing lists. It is available in http://www.skeeve.com/gawk/gawk-4.1.65.tar.gz 1 and he mentions that This…
fedorqui
  • 275,237
  • 103
  • 548
  • 598
2
votes
7 answers

Sorting alphabetically using last column, using awk

I am trying to sort a variable number of columns of text, sometimes there are 3 fields sometimes there are 2. Example input: George W. Bush Brack Obama Micky Mouse John F. Kennedy Desired result: George W.…
humbleSquid
  • 57
  • 2
  • 8
2
votes
2 answers

Passing BASH arguments to gawk at command line

I want to make a simple gawk script to extract the nth column of some file. The name of the file and the value for n I want to be entered at the command line. This script I make executable with chmod +x. Thus to extract the third column from the…
Tim
  • 291
  • 2
  • 17
2
votes
4 answers

Merge multiple input files with awk

I am trying to merge the contents of multiple files based on a key matching with awk, I have seen solutions only for two input files, but not more. The input files look like…
BernatL
  • 72
  • 10
2
votes
3 answers

In AWK (or GAWK), how to determine where does n-th word start?

Example: n=3, the input is foo bar baz a b c d e f g h 12 34 5 678 the output should be: 13 5 8
user31264
  • 6,557
  • 3
  • 26
  • 40