Hi,
Can someone help me with creating a bash shell script.
I need to create a script that gets a positive number n as an argument.
The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
I have 3 variables with different information.. they look like this (row-wise aswell):
Variable1 =
Roland
Kalle
Dalius
Variable2 =
ake123
ler321
kaf434
Variable3 =
Richardsen
Sworden
Lokthar
How can I sort them by variable3 alphabetical and add them into the same output so... (0 Replies)
Hi,
I have a problem that I am trying to solve and would greatly appreciate some input to solve this. I have a file containing variable length of line. Each line in the file has values separated by "," and i need to grep for these values in a some files. For example below is a sample file with 3... (12 Replies)
i'm trying to write a script that has 2 variables, and uses the 1st variable as a number and the 2nd a name to create directories. so if you typed in ./myscript 5 week, it would create 5 directories named week1 - week5. whenever i run this, i get an error message saying week5 already exists, so i... (3 Replies)
first time poster here
Im pretty new to grep and linux in general and I spent pretty much all day yesterday researching and coming up with a grep command to help with my university project. I am attempting to create a proof of concept bash script to scan the network using ngrep, find appropriate... (7 Replies)
Greetings all,
Been trying to do my Googling and forum searches but can't seem to lock in on a solution.
I have a script that parses a log and collects all the uniq events to a flat file. Some days might have 50 unique events, other days might have 75. (Hence my reference to dynamic.)
... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Here is what I am supposed to do, word for word from my assignment page:
1. Create/modify and print a... (2 Replies)
Sometimes it is handy to protect long scripts in C++.
The following syntax works fine for simple commands:
#define SHELLSCRIPT1 "\
#/bin/bash \n\
echo \"hello\" \n\
"
int main ()
{
cout <<system(SHELLSCRIPT1);
return 0;
}
Unfortunately for there are problems for:
1d arrays:... (10 Replies)
Trying to do so
echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies
LEARN ABOUT PHP
var_export
VAR_EXPORT(3) 1 VAR_EXPORT(3)var_export - Outputs or returns a parsable string representation of a variableSYNOPSIS
mixed var_export (mixed $expression, [bool $return = false])
DESCRIPTION var_export(3) gets structured information about the given variable. It is similar to var_dump(3) with one exception: the returned represen-
tation is valid PHP code.
PARAMETERS
o $expression
- The variable you want to export.
o $return
- If used and set to TRUE, var_export(3) will return the variable representation instead of outputting it.
RETURN VALUES
Returns the variable representation when the $return parameter is used and evaluates to TRUE. Otherwise, this function will return NULL.
NOTES
Note
When the $return parameter is used, this function uses internal output buffering so it cannot be used inside an ob_start(3) callback
function.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.1.0 | |
| | |
| | Possibility to export classes and arrays con- |
| | taining classes using the __set_state() magic |
| | method. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
var_export(3) Examples
<?php
$a = array (1, 2, array ("a", "b", "c"));
var_export($a);
?>
The above example will output:
array (
0 => 1,
1 => 2,
2 =>
array (
0 => 'a',
1 => 'b',
2 => 'c',
),
)
<?php
$b = 3.1;
$v = var_export($b, true);
echo $v;
?>
The above example will output:
3.1
Example #2
Exporting classes since PHP 5.1.0
<?php
class A { public $var; }
$a = new A;
$a->var = 5;
var_export($a);
?>
The above example will output:
A::__set_state(array(
'var' => 5,
))
Example #3
Using __set_state() (since PHP 5.1.0)
<?php
class A
{
public $var1;
public $var2;
public static function __set_state($an_array)
{
$obj = new A;
$obj->var1 = $an_array['var1'];
$obj->var2 = $an_array['var2'];
return $obj;
}
}
$a = new A;
$a->var1 = 5;
$a->var2 = 'foo';
eval('$b = ' . var_export($a, true) . ';'); // $b = A::__set_state(array(
// 'var1' => 5,
// 'var2' => 'foo',
// ));
var_dump($b);
?>
The above example will output:
object(A)#2 (2) {
["var1"]=>
int(5)
["var2"]=>
string(3) "foo"
}
NOTES
Note
Variables of type resource couldn't be exported by this function.
Note
var_export(3) does not handle circular references as it would be close to impossible to generate parsable PHP code for that. If you
want to do something with the full representation of an array or object, use serialize(3).
Warning
When var_export(3) exports objects, the leading backslash is not included in the class name of namespaced classes for maximum com-
patibility.
SEE ALSO print_r(3), serialize(3), var_dump(3).
PHP Documentation Group VAR_EXPORT(3)