Sponsored Content
Top Forums Shell Programming and Scripting Help! Yet another check element in array Question Post 302441144 by alan on Thursday 29th of July 2010 10:57:04 AM
Old 07-29-2010
Quote:
Originally Posted by zaxxon
You could try
Code:
if [[ $i != *.ctl ]]

In bash it seems if you use double square brackets, that the wildcard is working. Single sq. brackets do not work - I guess test is a bit limited to the shell built-in:

Code:
$> VAR=12345.ctl
$> [ $VAR == *.ctl ] && echo found
$> [[ $VAR == *.ctl ]] && echo found
found



---------- Post updated at 09:18 AM ---------- Previous update was at 09:10 AM ----------

Oh and I didn't notice at first:

Checking $i will not help since it is just a counter for your array and will contain only a number, if I am correct.

Better check something like ${HDD_LIST_Array[$i]}
Thanks for your reply.

I realized I needed to compare the element of the array instead of some value...which is what I was doing.

I tried this:

Code:
i=`echo ${HDD_LIST_Array[0]} | awk -F . '{print $NF}'`
if [ "$i" != "ctl" ]
  then
    echo "Control file not found!" ; exit 2;
fi

It worked.

Al.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

accessing my first element of array

Hello everyonel, I have an array set like so num=4 read name arr=name I go through while loop to assign different values to different array element from 1 to 4. when I try to access the FIRST element of the array I get the last one first. Like if I say ${arr} it will show the last element... (4 Replies)
Discussion started by: afadaghi
4 Replies

2. Shell Programming and Scripting

A final question! Compare character with each array element

qwrtyuiop666yhh (1 Reply)
Discussion started by: rorey_breaker
1 Replies

3. Shell Programming and Scripting

Shift array element

I want to delete and 0th element of array in shell scrpit and also shift all others to one level up. (2 Replies)
Discussion started by: darshakraut
2 Replies

4. 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

5. 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

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

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

8. Shell Programming and Scripting

How to insert an array element within regex?

Hello to all, I'm trying to separate the string "str" using a regex within match function. The substrings that I want to separate, begin with 22, 23, 24 or 25 and followed by 12 or 14 characters. And I want to replace 22 with MJS, 23 with UYT, 24 with WER and 25 with PIL. For this string... (4 Replies)
Discussion started by: Ophiuchus
4 Replies

9. 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

10. Shell Programming and Scripting

Awk: check element in array and it's value

Hello, I want to see if element exists in array, if so then, check it's corresponding value. Column 4 is position and column 1 is the chromosome for it. There are duplicates for one position on one chromosome. I want to check if same position exists on different chromosome: Data... (8 Replies)
Discussion started by: genome
8 Replies
EDAC-CTL(8)							EDAC admin utility						       EDAC-CTL(8)

NAME
edac-ctl - EDAC admin utility SYNOPSIS
edac-ctl [OPTION]... DESCRIPTION
The edac-ctl program is a perl(1) script which performs some useful administration tasks for EDAC (Error Detection and Correction) drivers. OPTIONS
--help Display a brief usage message. --mainboard Print mainboard vendor and model for this hardware, if available. The method used by edac-ctl to obtain the mainboard vendor and model information for the current system is described below in the MAINBOARD CONFIGURATION section. --status Print the status of EDAC drivers (loaded or unloaded). --register-labels Register motherboard DIMM labels into EDAC driver sysfs files. This option uses the detected mainboard manufacturer and model num- ber in combination with a "labels database" found in any of the files under /etc/edac/labels.d/* or in the labels.db file at /etc/edac/labels.db. An entry for the current hardware must exist in the labels database for this option to do anything. --print-labels Display the configured labels for the current hardware, as well as the current labels registered with EDAC. --labeldb=DB Specify an alternate location for the labels database. MAINBOARD CONFIGURATION
The edac-ctl script uses the following method to determine the current system's mainboard vendor and model information: 1. If the config file /etc/edac/mainboard exists, then it is parsed by edac-ctl. The mainboard config file has the following simple syn- tax: vendor = <mainboard vendor string> model = <mainboard model string> script = <script to gather mainboard information> Where anything after a '#' character on a line is considered a comment. If the keyword script is specified, then that script or exe- cutable is run by edac-ctl to gather the mainboard vendor and model information. The script should write the resulting information on stdout in the same format as the mainboard config file. 2. If no mainboard config file exists, then edac-ctl will attempt to read DMI information from the sysfs files /sys/class/dmi/id/board_vendor /sys/class/dmi/id/board_name 3. If the sysfs files above do not exist, then edac-ctl will fall back to parsing output of the dmidecode(8) utility. Use of this utility will most often require that edac-ctl be run as root. SEE ALSO
edac(3), edac-util(1) edac-utils-0.18-1 2011-11-09 EDAC-CTL(8)
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy