Not sure what OS or shell you're using but the output might be a bit much for a normal variable. Instead, you could try storing the returned output in an array:
How do I evaluate the result of a command assigned to a variable??
Example:
var1=`cmd`
rc=$?
rc will be the result of the assignment rather than cmd since it executes after. How do I evaluate the result of the command itself?
Cheers..:confused: (2 Replies)
Hi,
I want to check if a variable has a value assigned to it or not.
I can do following -
cat $Var > File1
if
then
echo "$Var has value"
else
echo "$Var is null"
fi
But I have to check for 3 Variables and I want to wrap it up in couple of unix statements.
Any... (3 Replies)
Hey ,
I'm trying to perform the following command, however it cannot read the variable assigned earlier. I'm not sure why this happen. Please help thanks
while :
do
echo "what's ur name? (if none just press )"
read name
changeName = echo $name | sed "s/on/ey/"
echo $changeName #this... (8 Replies)
I am making of a script that will go through a couple of for loops and create file names based on the values in that loop, however the variable that combines everything is not getting assigned properly:
#! /bin/bash
for imod in K33_j1b_WS9_6
do
for emod in mb2A mb2C mb3A mb3C mb4A... (1 Reply)
The requirement is, there is a log file which contains a huge data. i need to get a particular field out of it by searching with another field.
ex:
2011-03-28 13:00:07,423 : millis=231 q={ call get_data_account(?,?,?,?,?) }, params=
i need to search for the word "get_data_account" in file... (1 Reply)
I am trying to check whether a variable has been assigned on the command line or not.
Here is what I did:
#!/usr/bin/bash
if( $variable == '\0')
{
print "variable was not assigned"
exit
}
else
NF = 2 {print $1, ""}
exit
fi
awk -f question1.awk variable = 58 letters.txt.
So... (3 Replies)
Hi there can anyone help me
here is my code
echo "Type in a positive number"
read X
I=2
while
do
if
then
echo "It is not prime"
break
else
if
then
echo "It is prime"
break
else
I=$(( $I + 1))
fi
fi (4 Replies)
I want to do 2 things in single line that is evaluating a command to get return code and store $2 of awk if the command exit code is 0.
eval "ade desc ${filename}@@/<branch_name> | grep Version | awk '{print $2}' 2>&1 1>/dev/null"
ret=$?
echo "$ret $val"
if
then
... (3 Replies)
Experts,
I'm having problems with the code below.
I'm trying to test $var2 for two different regexs.
I thought it could be done per below, but I'm getting the following error when running.
$ ./test.pl b fed50c0100****
Unescaped left brace in regex is deprecated, passed through in regex; marked... (2 Replies)
Discussion started by: timj123
2 Replies
LEARN ABOUT PHP
splfixedarray
SPLFIXEDARRAY(3) 1 SPLFIXEDARRAY(3)The SplFixedArray classINTRODUCTION
The SplFixedArray class provides the main functionalities of array. The main differences between a SplFixedArray and a normal PHP array is
that the SplFixedArray is of fixed length and allows only integers within the range as indexes. The advantage is that it allows a faster
array implementation.
CLASS SYNOPSIS
SplFixedArray
SplFixedArrayIteratorArrayAccessCountable
Methods
o public SplFixedArray::__construct ([int $size])
o public int SplFixedArray::count (void )
o public mixed SplFixedArray::current (void )
o publicstatic SplFixedArray SplFixedArray::fromArray (array $array, [bool $save_indexes = true])
o public int SplFixedArray::getSize (void )
o public int SplFixedArray::key (void )
o public void SplFixedArray::next (void )
o public bool SplFixedArray::offsetExists (int $index)
o public mixed SplFixedArray::offsetGet (int $index)
o public void SplFixedArray::offsetSet (int $index, mixed $newval)
o public void SplFixedArray::offsetUnset (int $index)
o public void SplFixedArray::rewind (void )
o public int SplFixedArray::setSize (int $size)
o public array SplFixedArray::toArray (void )
o public bool SplFixedArray::valid (void )
o public void SplFixedArray::__wakeup (void )
EXAMPLES
Example #1
SplFixedArray usage example
<?php
// Initialize the array with a fixed length
$array = new SplFixedArray(5);
$array[1] = 2;
$array[4] = "foo";
var_dump($array[0]); // NULL
var_dump($array[1]); // int(2)
var_dump($array["4"]); // string(3) "foo"
// Increase the size of the array to 10
$array->setSize(10);
$array[9] = "asdf";
// Shrink the array to a size of 2
$array->setSize(2);
// The following lines throw a RuntimeException: Index invalid or out of range
try {
var_dump($array["non-numeric"]);
} catch(RuntimeException $re) {
echo "RuntimeException: ".$re->getMessage()."
";
}
try {
var_dump($array[-1]);
} catch(RuntimeException $re) {
echo "RuntimeException: ".$re->getMessage()."
";
}
try {
var_dump($array[5]);
} catch(RuntimeException $re) {
echo "RuntimeException: ".$re->getMessage()."
";
}
?>
The above example will output:
NULL
int(2)string(3) "foo"
RuntimeException: Index invalid or out of range
RuntimeException: Index invalid or out of range
RuntimeException: Index invalid or out of range
PHP Documentation Group SPLFIXEDARRAY(3)