![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP arrays as array elements | JerryHone | Shell Programming and Scripting | 3 | 12-29-2008 05:13 AM |
| Accessing array elements | mansa | Shell Programming and Scripting | 1 | 10-30-2008 06:28 AM |
| Deleting Array Elements | msb65 | UNIX for Dummies Questions & Answers | 3 | 10-21-2008 02:29 PM |
| Rearrange array elements-Pls help | tj23 | Shell Programming and Scripting | 4 | 06-20-2008 09:29 AM |
| To return the elements of array | Sudhakar333 | Shell Programming and Scripting | 5 | 08-06-2007 02:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
awk - array elements as condition
Hi,
can I use array elements ( all ) in conditional statements? the problem is ,the total number of elements is not known. e.g A is an array with elements - 1,2,3 now if i want to test if the 1 st field of input record is either 1,2 or 3, i can do something like this Code:
if ( $1 ~ /^A[1]$|^A[2]$|^A[3]$/) { print YES }
Code:
if ( $1 ~ /^A[1]$|^A[2]$|^A[3]$/| logical OR till array's last element) { print YES }
Is that possibe? |
|
||||
|
When you say:
Code:
$1 ~ /^A[1]$/ Code:
$1 == A[1] Have a look at: The GNU Awk User's Guide (7.5 Scanning All Elements of an Array) |
| Sponsored Links | ||
|
|