10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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)
Discussion started by: Riker1204
19 Replies
2. Shell Programming and Scripting
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)
Discussion started by: u20sr
11 Replies
3. UNIX for Dummies Questions & Answers
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)
Discussion started by: beca123456
12 Replies
4. Shell Programming and Scripting
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)
Discussion started by: akshaykr2
19 Replies
5. Shell Programming and Scripting
$ cat file.txt
A|X|20
A|Y|20
A|X|30
A|Z|20
B|X|10
A|Y|40
Summing up $NF based on first 2 fields,
$ awk -F "|" 'BEGIN {OFS="|"}
{ sum += $NF }
END { for (f in sum) print f,sum }
' file.txt
o/p:
A|X|50
A|Y|60
A|Z|20 (4 Replies)
Discussion started by: uwork72
4 Replies
6. Shell Programming and Scripting
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)
Discussion started by: jolecanard
2 Replies
7. Shell Programming and Scripting
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)
Discussion started by: youareapkman
4 Replies
8. UNIX for Dummies Questions & Answers
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)
Discussion started by: sairamdevotee
1 Replies
9. Filesystems, Disks and Memory
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)
Discussion started by: sairamdevotee
0 Replies
10. Shell Programming and Scripting
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)
Discussion started by: aami_sayan
2 Replies