It will be easy if you give the actual command.
Let us say you want to give:
Then try:
This tells the shell that what follows is not an option but a param.
I have a script which take 3 input parameters
1st - a date (i.e. current date)
2nd - type (i.e. A)
3rd - limit (i.e. 40)
normally the date parameter would be current date, so I thought I could do this
calculate.sh $(date +%Y-%m-%d) A 40
however, it seems like it can't be done,... (3 Replies)
Hi,
Can anyone explain what is going on here:
michael-browns-powerbook-g4-15:~ msb65$ start=-1
michael-browns-powerbook-g4-15:~ msb65$ stop=1
michael-browns-powerbook-g4-15:~ msb65$ if ; then echo hello; fi
-bash: ; then echo hello; fi
hello
Are you not allowed to compare negative... (6 Replies)
Hello,
For my weather station I have made a little perl script to put the data into cacti. The next problem I have.
I can only get positive numbers or negative numbers.
What do I do:
Though a shell scrip I call the perl script.
Shell script:
#!/bin/sh
cat data.txt | stats.pl
Perl... (4 Replies)
Let, I have three numbers
+00123.25
-00256.54
+00489.23
I need to sum up all those three numbers, after storing them in three variables (say var1, var2, var3).
I used both expr and BC, but they didn't work for me.
But, I am not able to sum up them, as I don't have any idea how to... (13 Replies)
ValA=-29344
if ; then
echo "NEGATIVE"
else
echo "POSITIVE"
fi
Can someone please tell me how else they would go about doing the above?
When i do it, i get errors such as: (10 Replies)
Dear All,
I have to split a tab delimited file in two files based on the presence of a positive or negative in column number 9 , for example
file:
A 1 5 erg + 6766 0.9889 0.9817 9.01882 erg inside upstream
B 1 8 erg2 + 6766 0.9889 0.9817 -9.22 erg2 inside... (3 Replies)
Greetings. I have a three column file, and there are some numbers in the second column that are <1. However I need all numbers to be positive, thus need to replace all those numbers with just one. I feel like there must be a simple way to use awk to find these numbers and sed to replace but can't... (5 Replies)
friends
and I can validate whether to run the shell has input parameters m event date, I occasionally happen something like this does not work
if $ 1 is null then
echo has entered input parameters
else
echo "parameter ok"
fi (2 Replies)
I have a file that is pipe delimited and in Column F they have number values, both positive and negative. I need to take the one file I am starting with and split it into two separate files based on negative and positive numbers. What is the command to do so? And then I need to also transfer... (4 Replies)
Discussion started by: cckaiser15
4 Replies
LEARN ABOUT PHP
array_slice
ARRAY_SLICE(3) 1 ARRAY_SLICE(3)array_slice - Extract a slice of the arraySYNOPSIS
array array_slice NULL (array $array, int $offset, [int $length], [bool $preserve_keys = false])
DESCRIPTION array_slice(3) returns the sequence of elements from the array $array as specified by the $offset and $length parameters.
PARAMETERS
o $array
- The input array.
o $offset
- If $offset is non-negative, the sequence will start at that offset in the $array. If $offset is negative, the sequence will
start that far from the end of the $array.
o $length
- If $length is given and is positive, then the sequence will have up to that many elements in it. If the array is shorter than
the $length, then only the available array elements will be present. If $length is given and is negative then the sequence will
stop that many elements from the end of the array. If it is omitted, then the sequence will have everything from $offset up until
the end of the $array.
o $preserve_keys
- Note that array_slice(3) will reorder and reset the numeric array indices by default. You can change this behaviour by setting
$preserve_keys to TRUE.
RETURN VALUES
Returns the slice.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.2.4 | |
| | |
| | The default value of the $length parameter was |
| | changed to NULL. A NULL$length now tells the |
| | function to use the length of $array. Prior to |
| | this version, a NULL$length was taken to mean a |
| | zero length (nothing will be returned). |
| | |
| 5.0.2 | |
| | |
| | The optional $preserve_keys parameter was added. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
array_slice(3) examples
<?php
$input = array("a", "b", "c", "d", "e");
$output = array_slice($input, 2); // returns "c", "d", and "e"
$output = array_slice($input, -2, 1); // returns "d"
$output = array_slice($input, 0, 3); // returns "a", "b", and "c"
// note the differences in the array keys
print_r(array_slice($input, 2, -1));
print_r(array_slice($input, 2, -1, true));
?>
The above example will output:
Array
(
[0] => c
[1] => d
)
Array
(
[2] => c
[3] => d
)
SEE ALSO array_splice(3), unset(3), array_chunk(3).
PHP Documentation Group ARRAY_SLICE(3)