Sponsored Content
Full Discussion: Compare bash arrays issue
Top Forums UNIX for Beginners Questions & Answers Compare bash arrays issue Post 303038729 by trexthurman on Thursday 12th of September 2019 11:10:06 AM
Old 09-12-2019
Your suggestions work for outputting to standard output but as I was testing the email portion, if there are 2 entries as differences - it treated them as 1 element in the array as oppose to 2 elements. I was hoping to have both differences in the array as its own element.

Code:
length=${#DIFF[@]}
for (( i=0; i<${length}; i++ ));
do
echo ${DIFF[i]}
done

# wrong result
Code:
DIFF[0] Mac me 
Windows
DIFF[0] Mac me Windows

# Desired result
Code:
DIFF[0] Mac me
DIFF[1] Windows


Last edited by Scrutinizer; 09-12-2019 at 02:40 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare two arrays in sh or compare two fields

I want a soultion to compare two arrays in sh with an easy way.I want a solution to synchrose users between different AIX servers where no NIS is available. All users are meant to be same on all 10 servers. So the approach is to consider first server as master user repository and whatever the users... (0 Replies)
Discussion started by: rijeshpp
0 Replies

2. Shell Programming and Scripting

Compare arrays in perl

Hello, Let's say that we have the two following arrays @array1= @array2= Is there any easy way to compare these two arrays and print the values that exist in array1 and not in array2 and the values that exist in array2 and not in array1? Regards, Chriss_58 (3 Replies)
Discussion started by: chriss_58
3 Replies

3. Shell Programming and Scripting

compare 2 arrays in perl

Hi Im supposed to compare lines in a file : KB0005 1019 T IFVATVPVI 0.691 PKC YES KB0005 1036 T YFLQTSQQL 0.785 PKC YES KB0005 1037 S FLQTSQQLK 0.585 DNAPK YES KB0005 1045 S KQLESEGRS 0.669 PKC YES KB0005 1045 S KQLESEGRS 0.880 unsp YES KB204320 1019 T IFVATVPVI 0.699 PKC YES ... (7 Replies)
Discussion started by: karla
7 Replies

4. Shell Programming and Scripting

Using Bash scripting to compare arrays looking for matches

I have two arrays I need to compare against a third, looking for matches, not differences. I think I'm going to have to convert the arrays to files and grep them, but I'm not too sure if there's a tool to enable me to matches specifically, instead of differences. Thanks in advance! Karl (9 Replies)
Discussion started by: karlp
9 Replies

5. Shell Programming and Scripting

Compare arrays (perl)

Hi, my first post here! Description of my problem: I have one txt-file with six rows and each row contains seven numbers seperated with whitespaces. I want to: Compare one array with seven numbers with each row of numbers in the txt-file. I have managed to compare one array with... (6 Replies)
Discussion started by: mjoh
6 Replies

6. Shell Programming and Scripting

Using arrays in bash using strings to bash built-in true

I have the following code and for some reason when I call the program using /home/tcdata/tatsh/trunk/hstmy/bin/bash/raytrac.bash --cmod=jcdint.cmod I get hasArgument = hasArgument = true Somehow the array element is returning even though I have not chosen the option. ... (41 Replies)
Discussion started by: kristinu
41 Replies

7. Shell Programming and Scripting

Bash arrays that compare ip addresses.

I've been trying to have an array of ip addresses go through a loop one at a time. Then compare if the current element is in another array of ip addresses. I've traced my error with /bin/bash -x + for c in '"${ip}"' ./netk5: line 65: 50.17.231.23 23.64.146.110 23.64.159.139 107.14.36.129... (17 Replies)
Discussion started by: Azrael
17 Replies

8. Shell Programming and Scripting

Compare two arrays

Hi, I am trying to compare two lists that are held in two variables so I believe I need to access the array elements to compare these. I am using ksh 88 and the code I have tried is below: for file in ${origfilelist} do if ]] then print -- "File ${file}... (3 Replies)
Discussion started by: frodo61
3 Replies

9. Shell Programming and Scripting

Using Diff to compare 2 arrays

I have two arrays and they look like this: array=(`cat /local/mnt/*sys/*includes|grep -v NEW`) array2=(`cat /tmp/*sys.z |grep -v NEW`) I am trying to compare them but I need to use the diff -u command. I am not sure how to do this. I cannot just do diff -u ${array} ${array2} I cannot... (4 Replies)
Discussion started by: newbie2010
4 Replies

10. Shell Programming and Scripting

Compare two arrays by values [BASH]

I have 2 arrays of values for example A1 ={10 15 3 21} A2 ={10 15 3 22} I need to check which one has greater values. However: A1 ={10 15 3 21} A2 ={10 15 3 21 3} - this one would be greater. A1 ={10 15 5 21} - this one greater A2 ={10 15 3 21} Basically, I want to compare patch... (6 Replies)
Discussion started by: Jutsimitsu
6 Replies
sediff(1)						      General Commands Manual							 sediff(1)

NAME
sediff - SELinux policy difference tool SYNOPSIS
sediff [OPTIONS] [EXPRESSION] ORIGINAL_POLICY ; MODIFIED_POLICY DESCRIPTION
sediff allows the user to inspect the semantic differences between two SELinux policies. POLICY
sediff supports loading SELinux policies in one of four formats. source A single text file containing policy source for versions 12 through 21. This file is usually named policy.conf. binary A single file containing a monolithic kernel binary policy for versions 15 through 21. This file is usually named by version - for example, policy.20. modular A list of policy packages each containing a loadable policy module. The first module listed must be a base module. policy list A single text file containing all the information needed to load a policy, usually exported by SETools graphical utilities. Policies do not need to be the same format. If not provided sediff will print an error message and exit. EXPRESSIONS
The user may specify an expression listing the policy elements to differentiate. If not provided, all supported policy elements sans nev- erallows are examined. -c, --class Find differences in permissions assigned to object classes and common permission sets. --level Find differences in categories authorized for MLS levels. --category Find differences in category definitions. -t, --type Find differences in attributes associated with types. -a, --attribute Find differences in types assigned to attributes. -r, --role Find differences in types authorized for roles. -u, --user Find differences in roles authorized for users. -b, --bool Find differences in the default values of booleans. -A, --allow Find differences in allow rules. --auditallow Find differences in auditallow rules. --dontaudit Find differences in dontaudit rules. --neverallow Find differences in neverallow rules. --type_trans Find differences in type_transition rules. --type_member Find differences in type_member rules. --type_change Find differences in type_change rules. --role_trans Find differences in role_transition rules. This includes differences in the default role. --role_allow Find differences in role allow rules. --range_trans Find differences in range_transition rules. This includes differences in the target MLS range. OPTIONS
-q, --quiet If there are no differences for elements of a given kind, suppress status output for that kind of element. --stats Print difference statistics only. -h, --help Print help information and exit. -V, --version Print version information and exit. DIFFERENCES
sediff categorizes differences in policy elements into one of three forms. added The element exists only in the modified policy. removed The element exists only in the original policy. modified The element exists in both policies but its semantic meaning has changed. For example, a class is modified if one or more permissions are added or removed. For all rules with types as their source or target, two additional forms of difference are recognized. This helps distinguish differences due to new types from differences in rules for existing types. added, new type The rule exists only in the modified policy; furthermore, one or more of the types in the rule do not exist in the original policy. removed, missing type The rule exists only in the original policy; furthermore, one or more of the types in the rule do not exist in the modified policy. NOTE
Most shells interpret the semicolon as a metacharacter, thus requiring a backslash like so: sediff original.policy ; modified.policy AUTHOR
This manual page was written by Jeremy A. Mowery <jmowery@tresys.com>. COPYRIGHT
Copyright(C) 2004-2007 Tresys Technology, LLC BUGS
Please report bugs via an email to setools-bugs@tresys.com. SEE ALSO
sediffx(1) sediff(1)
All times are GMT -4. The time now is 07:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy