Questions tagged [nawk]

`nawk` is a pattern scanning and processing language.

A nawk program is a sequence of patterns and corresponding actions.

The string specifying program must be enclosed in single quotes (') to protect it from interpretation by the shell.

The sequence of pattern - action statements can be specified in the command line as program or in one, or more, file(s) specified by the -f progfile option.

When input is read that matches a pattern, the action associated with the pattern is performed.

125 questions
1
vote
5 answers

Selecting surrounding lines around the missing sequence numbers

I have one file inside that file it is present as given…
gyrous
  • 189
  • 3
  • 6
  • 19
1
vote
2 answers

Trouble with nawk and OFS in BASH

I am working on a script to extract the processor set number followed by the processor ids that fall under that processor set in Solaris in bash shell: Here is the output I want to extract from: (contents of $output) user processor set 1:…
tomkaith13
  • 1,717
  • 4
  • 27
  • 39
1
vote
1 answer

How can I name a variable dynamically in awk?

I have requirement where first "n" rows ("n" being variable passed at run time) should be stored in "n" corresponding arrays, array name being named as arrayRow"NR"; here, NR is the built-in awk variable. awk -F"," -v n=$Header_Count…
1
vote
3 answers

Adding a delimiter after each file processed within awk

I have multiple files where I am extracting text between two delimiters (START and END non-inclusive). After I process each file I want to output a delimiter indicating the file was processed, say the string "END". How would I add the string "END"…
GregH
  • 12,278
  • 23
  • 73
  • 109
1
vote
3 answers

UNIX:How to convert ip address to binary code

Is there is any Command to convert ip address in to binary form? Eg: 10.110.11.116 output: 00001010.01101110.00001011.01110100
gyrous
  • 189
  • 3
  • 6
  • 19
1
vote
2 answers

Given a list of numbers in a field, how to sum them and print them in an (n)awk script?

Given this list of names and numbers: Kirilienko:47 James:23 Bryant:24 Durant:35 Griffin:32 How would I find sum the numbers in the second field and print them in an awk script, in the sentence: print "The total number of these five players is…
Anonymous
  • 411
  • 1
  • 4
  • 14
1
vote
4 answers

Problem with replace command

I have some problem with replace command. Input file i have this {a[$1]=a[$1]FS$2}END{for(i in a) print i,a[i]} I want to replace with single quotes '{a[$1]=a[$1]FS$2}END{for(i in a) print i,a[i]}' Using the below mentioned command find input.txt…
gyrous
  • 189
  • 3
  • 6
  • 19
1
vote
4 answers

How to delete last two lines of an output using AWK?

i am trying to make a graphic representation of an output that shows the free memory of the server of the current day (which is shown approximetaly by hour), from that output i dont want the first two lines and last two, the first two i can easy…
Sir. Hedgehog
  • 1,260
  • 3
  • 17
  • 40
1
vote
3 answers

how can i print the column in text file to row wise using unix command?

I have file like this.. for…
gyrous
  • 189
  • 3
  • 6
  • 19
1
vote
1 answer

awk regex for repeated character

I'm trying to match repeated patterns in strings. I know i can use /^[0-9]{5}$/ at least in perl, but this doesn't seem to work in awk or nawk (no gawk installed). Any alternative, other than /^[0-9][0-9][0-9][0-9][0-9]$/ ? EDIT: echo "AAB" >…
vesperto
  • 804
  • 1
  • 6
  • 26
1
vote
1 answer

text into json using awk or nawk

I have following text file to process **parent** father = erik mother = rita *son* name = john age = 13 *daughter* name = lili age = 24 status = student **parent** father = boby mother = christa *son* name = tim age = 2 …
6axter82
  • 569
  • 2
  • 8
  • 19
1
vote
0 answers

Why does the command only work in gawk?

I have 2 hosts: one is running Linux, while the other is OmniOS. The awk on Linux is gawk: [root@localhost ~]# which awk /bin/awk [root@localhost ~]# ls -lt /bin/awk lrwxrwxrwx. 1 root root 4 Jan 22 2014 /bin/awk -> gawk And running the…
Nan Xiao
  • 16,671
  • 18
  • 103
  • 164
1
vote
1 answer

Solaris Convert Get Last Hour of Logs by Comparing the Timestamps

I have a log that looks like this: #### <[ACTIVE] ExecuteThread: '17' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <> <1410913515898>
Ken J
  • 4,312
  • 12
  • 50
  • 86
1
vote
2 answers

"nawk if else if else" not working

ok, this is most probably going to sound like a stupid question to you, but I can't make it work and really don't know what I do wrong here even after reading quite a few nawk/awk help sites: $ echo -e "hey\nthis\nworld" | nawk '{ if ( $1 !~ /e/…
hermann
  • 13
  • 2
1
vote
2 answers

AWK split file needs to a close

I have a text file that looks like this: valcred: requestValCred [up] certificate pki_001 [up] certificate pki_002 [up] certificate pki_003 [up] certificate pki_004 [up] certificate pki_005 [up] valcred: internalValCred [up] certificate…
1 2
3
8 9