I am trying to reformat the table by filling any missing rows. The final table will have consecutive IDs in the first column. My problem is the index of the associate array in the awk script.
where S04, S08 & S09 are missing. And I am expecting the output as
I have adapted the scripts of Schrutinizer from my previous post as
But the output is
which has concatenated IDs in the first column.
The fix is to add an extra line between Line7 and Line8. $1="" which is to empty $1 after each line.
I need elaboration how this new line works in awk.
Thanks a lot!
hi,
i have 3 fields in a file and linked them through 2 associative arrays.. the problem is one of the associative array is working while the other is not.. the code part is:
awk ' BEGIN {
FS="|"
rc = getline < "ICX_RULES"
while ( rc == 1 )
{
rule_id=$1
rule_parameter=$2... (2 Replies)
why do inode indices starts from 1 unlike array indexes which starts from 0
its a question from "the design of unix operating system" of maurice j bach
id be glad if i get to know the answer quickly
:) (0 Replies)
brothers why inode index starts from 1 unlike array inex which starts from 0
its a question from the design of unix operating system of maurice j.bach
i need to know the answer urgently...someone help please (1 Reply)
I come across the problems when assigning the array in the script below . How to use the array with the 'string index' correctly ? When I assign a new string index , the array elements that are previously assigned are all changed .:eek::eek::eek:
$ array=211
$ echo ${array}
211
$... (4 Replies)
Hello,
I have this code:
#!/bin/sh
awk -v val="........." 'BEGIN{FS=OFS=" ";c=0}
NR==FNR&&d==0{a=$0; c++;next}
FNR==(NR-c){b=val;next}
{if(1234 in a){print "okay"}}
{print $1}' listi fpr.11 grn
that is working (awk find the value in the table "a" and return "okay" followed by 1234)
... (2 Replies)
I am beginner in awk
awk 'BEGIN{for(i=1;(getline<"opnoise")>0;i++) arr=$1}{print arr}'
In the above script, opnoise is a file, I am reading it into an array and then printing the value corresponding to index 20. Well this is not my real objective, but I have posted this example to describe... (19 Replies)
Hi!
Let's say I would like to convert "1", "2", "3" to "a", "b", "c" respectively. But if a record contains other number then return "X".
input:
1
2
3
4
output:
a
b
c
X
What is the syntax for:
if(array doesn't contain a particular index){
then print the value "X" instead} (12 Replies)
Can you search AWK array elements and return each index value for that element.
For example an array named car would have index make and element engine. I want to return all makes with engine size 1.6.
Array woulld look like this:
BMW 1.6
BMW 2.0
BMW 2.5
AUDI 1.8
AUDI 1.6
... (11 Replies)
I am trying to assign indexes to an associative array in a for loop but I have to use an eval command to make it work, this doesn't seem correct I don't have to do this with regular arrays
For example, the following assignment fails without the eval command:
#! /bin/bash
read -d "\0" -a... (19 Replies)