10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Am using bash
For eg:
Suppose i have a array
arr=(1 2 3 4 5 6 7 8 9 10 11 12)
suppose i give input 5 to a script and script should able to print values greater than or equal to 5 like below:
Input:
5
output:
5,6,7,8,9,10,11,12 (7 Replies)
Discussion started by: manid
7 Replies
2. Shell Programming and Scripting
I have never used arrays before but I have a script like this:
var1=$(for i in $(cat /tmp/jobs.021013);do $LIST -job $i -all |
perl -ne 'print /.*(\bInfo.bptm\(pid=\d{3,5}).*/' | tr -d "(Info=regpid" | tr -d ')'; $LIST -job $i -all |
cut -f7 -d','| sed -e "s/^\(*\)\(*\)\(*\)\(.*\)/\1... (2 Replies)
Discussion started by: newbie2010
2 Replies
3. Programming
I've noticed something interesting in C++ programming. I've always done tricky stuff with pointers and references to have functions deal with arrays. Doing exercises again out of a C++ book has shown me an easier way, I didn't even know was there. It's weird to me.
When dealing with arrays, it... (4 Replies)
Discussion started by: John Tate
4 Replies
4. Shell Programming and Scripting
Hi all,
I have a file test1.txt with the below contents
abc
def
ghj
xyz
I tried printing these values using arrays.
Script tried :
===========
set -A array1 `cat test1.txt`
count=${#array1
}
i=0
while
do
echo "element of array $array1"
done (1 Reply)
Discussion started by: dnam9917
1 Replies
5. Programming
if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies
6. Shell Programming and Scripting
Hi all.
I'm trying to finish a bash script with the following elements:
ARRAY="blah $ITEM blah blah"
ARRAY="blah blah $ITEM blah bluh"
#ARRAY="...."
# ...the ARRAY elements represent a variable but defined
# syntax and they're all hard-coded in the script.
#(...)
ITEMS='1.0 2.3... (2 Replies)
Discussion started by: yomaya
2 Replies
7. Shell Programming and Scripting
Hi
I am having text file like this
001|ramu|hno221|><
sheshadripuram|delhi|560061><
002|krishna|hno225|><
newdelhimain|delhi|560061><
i want to combine every two lines as single...line...
i.e
001|ramu|hno221|sheshadripuram|delhi|560061
can u pls help me (3 Replies)
Discussion started by: suryanarayana
3 Replies
8. UNIX for Dummies Questions & Answers
Hello,
I am some what of a newbie to awk scripting and I seem to be struggling with this problem.
I know I need to use arrays but I can't figure out how to use them.
I have an input file that looks like this;
Name,Team,First Test, Second Test, Third Test
Crystal,Red,5,17,22... (1 Reply)
Discussion started by: vlopez
1 Replies
9. Web Development
PHP question...
I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names.
So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person with values "Fred", "Bert", "Tom" etc
So what I want to do is display the... (3 Replies)
Discussion started by: JerryHone
3 Replies
10. Shell Programming and Scripting
Dear all,
How can i unset arrays. I mean all the subscripts including the array after using them.
Could you direct me to some links of array memory handling in the korn shell.
Thanks (2 Replies)
Discussion started by: earlysame55
2 Replies
ARRAY_INTERSECT_UKEY(3) 1 ARRAY_INTERSECT_UKEY(3)
array_intersect_ukey - Computes the intersection of arrays using a callback function on the keys for comparison
SYNOPSIS
array array_intersect_ukey (array $array1, array $array2, [array $...], callable $key_compare_func)
DESCRIPTION
array_intersect_ukey(3) returns an array containing all the values of $array1 which have matching keys that are present in all the argu-
ments.
PARAMETERS
o $array1
- Initial array for comparison of the arrays.
o $array2
- First array to compare keys against.
o $...
- Variable list of array arguments to compare keys against.
o $key_compare_func
- The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to
be respectively less than, equal to, or greater than the second.
int callback (mixed $a, mixed $b)
RETURN VALUES
Returns the values of $array1 whose keys exist in all the arguments.
EXAMPLES
Example #1
array_intersect_ukey(3) example
<?php
function key_compare_func($key1, $key2)
{
if ($key1 == $key2)
return 0;
else if ($key1 > $key2)
return 1;
else
return -1;
}
$array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
var_dump(array_intersect_ukey($array1, $array2, 'key_compare_func'));
?>
The above example will output:
array(2) {
["blue"]=>
int(1)
["green"]=>
int(3)
}
In our example you see that only the keys 'blue' and 'green' are present in both arrays and thus returned. Also notice that the values for
the keys 'blue' and 'green' differ between the two arrays. A match still occurs because only the keys are checked. The values returned are
those of $array1.
SEE ALSO
array_diff(3), array_udiff(3), array_diff_assoc(3), array_diff_uassoc(3), array_udiff_assoc(3), array_udiff_uassoc(3), array_diff_key(3),
array_diff_ukey(3), array_intersect(3), array_intersect_assoc(3), array_intersect_uassoc(3), array_intersect_key(3).
PHP Documentation Group ARRAY_INTERSECT_UKEY(3)