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

Eliminating the duplicates from a specific column

Let say i have a file as below MGW24:EXT-1:YES:OK MGW24:SET-4:NO:OK MGW24:SET-132:NO:OK I want to check the column one and see if it repeats. In case if any string got repeats i want to eliminate the duplicates and print rest of the columns as it…
suren
  • 1
-2
votes
1 answer

How to each nth line a a column using awk?

I have a single column text file looking like this: John Doe Male 1984 Marie Parker Female 1989 And I would like to convert it to look like this: John Doe Male 1984 Marie Parker Female 1989 I've tried using awk and modulo but I cannot manage to…
amplicon
  • 1
  • 1
-2
votes
5 answers

using awk or sed to print all columns from the n-th to the last

This is NOT a duplicate of another question. All previous questions/solutions posted on stackoverflow have got the same issue: additional spaces get replaced into a single space. Example (1.txt) filename Nospaces filename One space filename Two …
meso_2600
  • 1,940
  • 5
  • 25
  • 50
-2
votes
1 answer

Appending whitespace to a variable in AWK script

I have an AWK script, which receives an input variable from another script. The length of the input variable is compared. if the length is 3, two whitespace is added infront of variable. If the length is 4, 1 whitespace is added in front. I could…
-2
votes
2 answers

how to edit following line in sed, awk or anything else

how to edit following line in sed, awk or anything else: root@laptop002:/tmp# cat /tmp/log 2016-03-01 06:08:26 {"id":"778640","cuid":"1","msid":"199033","lid":"582","Started":"1","qid":"9401"} batch is running to make it look like…
solaris
  • 15
  • 2
-2
votes
1 answer

Formatting data output using AWK

Can you help me how use awk to scan this Control-m output ? It's a Control-m output and I need format it. ORDERID JOBNAME TYPE ODATE STATE STATUS FROMTIME UNTIL -------- ----------------- ---- ------- ------- ------ --------…
user2707722
  • 51
  • 2
  • 8
-2
votes
1 answer

AWK: Merge columns in a CSV file

The file is sorted by the column 7, and it needs to combine fields 11, 12, 13, 14, 15 and 16, for each group of lines with the same ID, which is the value of the column 7. I finally solved my problem alone, thanks to all!!. What I have…
Polucho
  • 23
  • 5
-2
votes
3 answers

How to match "field 5 through the end of the line" (for example, in awk)

I want to pretty-print the output of a find-like script that would take input like this: - 2015-10-02 19:45 102 /My Directory/some file.txt and produce something like this: - 102 /My Directory/some file.txt In other words: "f" (for…
Tom Baker
  • 683
  • 5
  • 17
-2
votes
1 answer

How to convert interger numbers into brazilain price format

i have integer numbers like below on left side in a file for products and need to convert them into brazilaian format like on right side. 100 =>100,00 84 => 84,00 1011 => 1.011,00
Chethu
  • 555
  • 4
  • 13
-2
votes
2 answers

not getting the latest against the uniq with awk

65 20150427 000000000 8 20120930 000000000 18 20130626 000000000 6 20140505 000000000 1 20150603 000000000 18 20140712 000000000 65 20150502 000000000 10 20150113 000000000 92 20140707 000001000 20 20130530 000000000 11 20141231 000000000 15…
-2
votes
1 answer

Replace - with ' ' with gawk

I have this data set Format ID date delimited-characters Here is a sample file FILE data.txt 004 06/23/1962 AAA-BBB-CCC-DDD 023 11/22/1963 AAA-BBB-CCC-DDD 070 06/23/1963 AAA-BBB-CCC-DDD My gawk script works fine like this call gawk 'BEGIN { BLANK…
Kent
  • 81
  • 1
  • 1
  • 4
-2
votes
2 answers

How to delete lines & populate based on particluar field in unix

I want to delete lines based on "CLIENT TOTAL" and the succeeding unit lines untill next name. The number of unit lines(i.e lines with 30.0 and 15.0) after "CLIENT TOTAL" line may vary untill the next name. Most importantly the file is not…
-2
votes
2 answers

If statement in GAWK gives an error

I have this piece of code: gawk '{if (match($5,/hola/,a) && $6=="hola") {print $2"\t"$1"\t"$2"\t"$1"\t"$3} else if `(match($5,/(_[joxT]+\.[0-9]*)/,a) && match($6,/(_[joxG]+\.[0-9]*)/,b)) {print $2""a[1]"\t"$1""b[1]} else…
user2886545
  • 711
  • 2
  • 8
  • 18
-2
votes
1 answer

Generate a HTML table report using AWK

I have my server logs, in the following format, is it possible to convert this in a tabular format ? Server Log:- ####<Jun 1, 2014 9:28:49 AM EDT> <Error> <JMX> <Host1> <pnbprod01> <[ACTIVE] ExecuteThread:…
Thiru Arasu
  • 49
  • 1
  • 7
-2
votes
2 answers

Matching lines with parentheses before double backslashes using regex in AWK

I've got an AWK script and I'm trying to check if lines coming into it have an ( but only if its before // or there is no // (its C code, so basically seeing if something happens before the comment). Right now I have if (match($0,/(\()/)) do…
Jedi Wolf
  • 331
  • 3
  • 13