11-26-2008
Compare Array results
Hi,
In a kshell , i need to compare the results of two array .
each Non-match value should copy to a new array.
For example:
==========
Array one contain the following values:
A
B
C
Array two contain the following values:
C
F
A
E
After comparing this arrays , a new array should be populated with the following values:
F
E
I will appreciate you help
Thank You
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
Can anybody tell me how can I dump the results of execution of a command into array form? For example, I want to execute:
and put each part of the result in an array element:
Thanks (2 Replies)
Discussion started by: alirezan
2 Replies
2. Shell Programming and Scripting
Hi All
I am going crazy trying to resolve this easy task....
I have a log file that is created by xcode; and it contains the results of a build (either success or fail); what i am trying to achieve here is to get the result from the log, and check if is a pass or fail in an IF statement, so... (3 Replies)
Discussion started by: newbiez
3 Replies
3. Shell Programming and Scripting
Hi ,
I am not familiar with shell programming. I have a requirement like i have two files
.I need to compare the two files by comparing each parameter and i should produce 2 outputs.
1)i have around 35 parameters say i have one parameter name called db_name=dcap in one file and... (7 Replies)
Discussion started by: muraliinfy04
7 Replies
4. Shell Programming and Scripting
I'm trying to add the paths of all the xml files in certain directories to an array. I want to use the array later in my code. Anyway, for some reason this isn't working. Any help would be appreciated.
Path_Counter=0
for result in "find * -name '*.xml'"; do
XmlPath="$result"
echo... (2 Replies)
Discussion started by: Fly_Moe
2 Replies
5. Shell Programming and Scripting
Hi, I just wondering if I want to compare previous value to next value if it same count + 1 if not doesn't count how do we compare in Perl? Thank (2 Replies)
Discussion started by: guidely
2 Replies
6. Shell Programming and Scripting
Hi firnds,
I am having two arrays
eg. @a=qw(1 2 3 4) and @b=qw(1 3 6 9)
Now, I want to compare two arrays on first index of both arrays and if they matched, it should output remaining indexes
Pseudo-code
if ($a == $b)
{ print "remaining indexes";}
How can i do this using perl? (1 Reply)
Discussion started by: Renesh
1 Replies
7. Shell Programming and Scripting
ok, so here is the issue, I have 2 arrays.
I need to be able to create a loop that will find ${ARRAY1 in the text doc, and replace it with ${ARRAY2 then write the results. I already have that working. The problem is, I need it to do that same result across however many items are in the 2... (2 Replies)
Discussion started by: gentlefury
2 Replies
8. Shell Programming and Scripting
Requirement 1) I need to execute 15 SQL queries in oracle through linux script. All these query results needs to be stored in array variables.
Requirement 2) And these 15 queries needs to be executed in parallel.
Requirement 3) Once all the queries executed then the shell script should... (3 Replies)
Discussion started by: Niranjancse
3 Replies
9. Shell Programming and Scripting
for a in {1..100}
do
awk '{ sum+=$a} END {print sum}' a=$a file1 > file2
done
I know I will get only one number if following the code above, how can I get 100 sum numbers in file2? (2 Replies)
Discussion started by: wanliushao
2 Replies
10. Programming
Can C add its results into an array like bash? For example using bash:
cat /etc/passwd
**truncated for space **
gdm:x:109:118:Gnome Display Manager:/var/lib/gdm:/bin/false
mysql:x:110:122:MySQL Server,,,:/nonexistent:/bin/false
statd:x:111:65534::/var/lib/nfs:/bin/false... (5 Replies)
Discussion started by: metallica1973
5 Replies
LEARN ABOUT PHP
array_chunk
ARRAY_CHUNK(3) 1 ARRAY_CHUNK(3)
array_chunk - Split an array into chunks
SYNOPSIS
array array_chunk (array $array, int $size, [bool $preserve_keys = false])
DESCRIPTION
Chunks an array into arrays with $size elements. The last chunk may contain less than $size elements.
PARAMETERS
o $array
- The array to work on
o $size
- The size of each chunk
o $preserve_keys
- When set to TRUE keys will be preserved. Default is FALSE which will reindex the chunk numerically
RETURN VALUES
Returns a multidimensional numerically indexed array, starting with zero, with each dimension containing $size elements.
ERRORS
/EXCEPTIONS
If $size is less than 1 E_WARNING will be thrown and NULL returned.
EXAMPLES
Example #1
array_chunk(3) example
<?php
$input_array = array('a', 'b', 'c', 'd', 'e');
print_r(array_chunk($input_array, 2));
print_r(array_chunk($input_array, 2, true));
?>
The above example will output:
Array
(
[0] => Array
(
[0] => a
[1] => b
)
[1] => Array
(
[0] => c
[1] => d
)
[2] => Array
(
[0] => e
)
)
Array
(
[0] => Array
(
[0] => a
[1] => b
)
[1] => Array
(
[2] => c
[3] => d
)
[2] => Array
(
[4] => e
)
)
SEE ALSO
array_slice(3).
PHP Documentation Group ARRAY_CHUNK(3)