Awk: check element in array and it's value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk: check element in array and it's value
# 8  
Old 11-20-2017
Hi, try:
Code:
(!($4 in CHR))

rather than
Code:
(! $4 in CHR)

# 9  
Old 11-20-2017
Got it. Thank you. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Awk: count unique element of array

Hi, tab-separated input: blabla_1 A,B,C,C blabla_2 A,E,G blabla_3 R,Q,A,B,C,R,Q output: blabla_1 3 blabla_2 3 blabla_3 5 After splitting $2 in an array, I am trying to store the number of unique elements in a variable, but have some difficulties resetting the variable to 0 before... (6 Replies)
Discussion started by: beca123456
6 Replies

2. UNIX for Advanced & Expert Users

Array Element

This question is for someone that's more familiar with Array Element. I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024? param_array="$param_nam" counter=$counter+1 #to avoid space... (3 Replies)
Discussion started by: cumeh1624
3 Replies

3. Shell Programming and Scripting

awk Search Array Element Return Index

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

4. Shell Programming and Scripting

Perl: How to check whether my array contains element x

Hi All, I am new to perl I am stuck in simple problem I need your help I want to define a subroutine. sub check_if_entity_exists(@array_to_be_checked,$entityName) I have array as http-listener-1 http-listener-2 http-listener-3 http-listener-4 If i send http-listener-3 my... (1 Reply)
Discussion started by: javaholics
1 Replies

5. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

Hello experts, I'm stuck with this script for three days now. Here's what i need. I need to split a large delimited (,) file into 2 files based on the value present in the last field. Samp: Something.csv bca,adc,asdf,123,12C bca,adc,asdf,123,13C def,adc,asdf,123,12A I need this split... (6 Replies)
Discussion started by: shell_boy23
6 Replies

6. Shell Programming and Scripting

Multiplying array element

I am trying to take all the elements of an array and multiply them by 2, and then copy them to a new array. Here is what I have i=0 for true in DMGLIST do let DMGSIZES2="${DMGSIZES}"*2 let i++ done unset i echo ${DMGSIZES2} It does the calculation correctly for the first element,... (7 Replies)
Discussion started by: nextyoyoma
7 Replies

7. Shell Programming and Scripting

remove an element from array

I need to remove an element from the below array variable TABLENAME. #!/bin/ksh set -A TABLENAME "mirf roxar keke mirs" echo "the array is ${TABLENAME}" If i need to remove say keke and have the final TABLENAME as below, how this could be achieved. Pls throw some light. echo "Modified... (3 Replies)
Discussion started by: michaelrozar17
3 Replies

8. Shell Programming and Scripting

Help! Yet another check element in array Question

Greetings, DISCLAIMER: My shell scripting is rusty so my question may be borderline stupid. You've been warned. I need to create a script that a) lists the content of zip files in a directory and b) sends out an `exception` report. My ZIP files contain a control file (for load check). I want... (2 Replies)
Discussion started by: alan
2 Replies

9. Shell Programming and Scripting

How to check index of a array element in shell script?

Example - Script to find the index of a month from array MONTHS="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec" set -A MON $MONTHS A="Sun May 23 09:34:30 GMT 2010" getMonth=`echo $A|cut -c5-7` ##getMonth=May Arrayindex_in_MONTHS_array= ???? # { 0,1,2,3,4 } - at fifth place ... (7 Replies)
Discussion started by: KuldeepSinghTCS
7 Replies

10. Shell Programming and Scripting

acessing awk array element while getline < "file"

I am attempting to write a awk script that reads in a file after awk array elements are assigned and using those elements while reading in the new file. Does this make sense? /pattern/ {tst=$3} (( getline < "file" ) > 0 ) { x=x " "tst } When I print tst in the END statement it... (9 Replies)
Discussion started by: timj123
9 Replies
Login or Register to Ask a Question