Sponsored Content
Top Forums Shell Programming and Scripting If test array element multiplication Post 303020320 by gtsonoma on Monday 16th of July 2018 06:52:14 PM
Old 07-16-2018
If test array element multiplication

Ya, I know, who in this day and age is mirroring rootvg...?
But yes, my shop does and I need to script checking for it.


I also know I could just inverse the the logic and call the LV mirrored
if the LPs and PPs were not equal. But I want to do the math in the if test
and also know I could use single element variables but array loading and usage is a learning experience for me.



Here is my script, but doing the math inside the if test is eluding me.


Code:
for LV in hd1 hd2 hd3 hd4 hd5
do
set -A LP_PP `lsvg -l rootvg |grep "$LV " |awk '{ print $3" "$4 }'`
if [[ ${LP_PP[0]} == ${LP_PP[1]} ]]       # [0] *2 = [1]
 then
  MRD=mirrored
 else
  MRD="NOT mirrored"
fi
print "$LV is $MRD"
done

 

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

Adding array element in KSH

All, I would like to add the first 10 elements of an array. Here is how I am doing it now (only included first few add ops): #!/usr/bin/ksh ###Grab the array values out of a file### TOTAL=`awk '/time/' /tmp/file.out | awk '{print $4}'` set -A times $TOTAL SUM=$((${times} + times... (3 Replies)
Discussion started by: Shoeless_Mike
3 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

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

5. Shell Programming and Scripting

previous element in the array perl

Hi, How to get previous/next element in the array perl Example @queue = (1, 2 ,3 , 4); I want to get value of 1 and 2, or, 2 and 3, or 3 and 4...etc and compare to value which one is greater to do that I need to get previous and next element of array ? (1 Reply)
Discussion started by: guidely
1 Replies

6. UNIX for Advanced & Expert Users

Perl XML::DOM: How to test if element exists?

Hi, I'm trying to write a script for some xml file handling, but I'm not getting too far with it. I've got the following xml content <?xml version="1.0" encoding="UTF-8"?> <Test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <Operation name="OPER1"> <Action name="ACTION1">... (2 Replies)
Discussion started by: Juha
2 Replies

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

8. Shell Programming and Scripting

ksh insert element in array

Hi all, I need help with the following scenario in ksh. If the number of elements contained by arrayA is 11 I need to insert a zero as the element arrayA then print all arrayA elements separated by comma. Appreciate your help. (9 Replies)
Discussion started by: ejianu
9 Replies

9. Shell Programming and Scripting

Multiplication of array elements

Hi, I can't find out how to create correct code to get multiplication of each elements of array. Let's say I enter array into command line (2 3 4 5 6 8) and i need output 2*3*4*5*6*8=5760. I tried this one, but answer is 0. for i in $@; do mult=$((mult*i))done echo "mult: " $mult ... (4 Replies)
Discussion started by: rimasbimas
4 Replies

10. 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
fribidi_get_mirror_char(3)					Programmer's Manual					fribidi_get_mirror_char(3)

NAME
fribidi_get_mirror_char - get mirrored character SYNOPSIS
#include <fribidi.h> fribidi_boolean fribidi_get_mirror_char ( FriBidiChar ch, FriBidiChar *mirrored_ch ); PARAMETERS
FriBidiChar ch Input character. FriBidiChar *mirrored_ch Output mirrored character. DESCRIPTION
This function finds the mirrored equivalent of a character as defined in the file BidiMirroring.txt of the Unicode Character Database available at http://www.unicode.org/Public/UNIDATA/BidiMirroring.txt. If the input character is a declared as a mirroring character in the Unicode standard and has a mirrored equivalent. The matching mir- rored character is put in the output, otherwise the input character itself is put. RETURNS
If the character has a mirroring equivalent or not. SEE ALSO
fribidi_charset_to_unicode(3), fribidi_unicode_to_charset(3), fribidi_parse_charset(3), fribidi_shape_arabic(3), fribidi_get_par_direc- tion(3), fribidi_get_par_embedding_levels(3), fribidi_reorder_line(3), fribidi_get_bidi_type(3), fribidi_get_bidi_types(3), fribidi_get_bidi_type_name(3), fribidi_debug_status(3), fribidi_mirroring_status(3), fribidi_set_mirroring(3), fribidi_reorder_nsm_sta- tus(3), fribidi_set_reorder_nsm(3), fribidi_log2vis_get_embedding_levels(3), fribidi_get_type(3), fribidi_get_type_internal(3), fribidi_remove_bidi_marks(3), fribidi_log2vis(3), fribidi_join_arabic(3), fribidi_get_joining_type(3), fribidi_get_joining_types(3), fribidi_get_joining_type_name(3), fribidi_shape_mirroring(3), fribidi_shape(3) GNU FriBidi 0.19.2 30 January 2006 fribidi_get_mirror_char(3)
All times are GMT -4. The time now is 11:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy