Hi Guys,
I am trying to do a file parse which is something like
config file:
machines= sha1 sha2 sha3 sha4
The bash script should be supporting upto 64 such machines
what I want is to place the machines in an array and then use the array to ssh to each machine.
The script I worte
... (11 Replies)
Hi,
How do I parse/split lines (strings) read from a file and display the individual tokens in a shell script? Given that the length of individual lines is not constant and number of tokens in each line is also not constant.
The input file could be as below:
... (3 Replies)
Hi all
I have a little brainscratcher here.
I want to draw a pie chart from data in a text file.
The drawing of the graph works fine, if I insert the data manually into a 2d array.
Now I want to pull the data from a text file (which was created using a uniq -c command) see sample below.... (2 Replies)
anybody know a nice way to parse long input parameters such as --path /dir1/dir2/ (see below). Now I have more than 10 input parameters and it's confusing having parameters like -q something, I would prefer longer ones
case $OPTKEY in
--path) M_PATH=$OPTARG ;;
-s) ... (3 Replies)
Hello,
Can somebody please give me a snippet for the below requirement.
I want to assign the values separeted by a comma to be assigned to a dynamic array.
If I give an input (read statement) like abc1,abc2,abc3,abc4,abc5, all these strings abc* should be assigned to an array like below... (2 Replies)
I would create a bash script than parse like this:
test.sh -p (protocol) -i (address) -d (directory)
I need retrive the value after -p for example...
understand???
I hope...
thanks (6 Replies)
I need to create a bash array from the command line parameters. I only know how to do it when I know the number of parameters. But what do I do when I dont know the number of parameters? (1 Reply)
I have two files that I am going to use diff to find the differences but need to parse them before I do that. I have include the format of each file1 and file2 with the desired output of each (the first 5 fields in each file). The first file has a "chr" before the # that needs to be removed. I... (1 Reply)
In the awk below I am trying to parse the Sample Name below the section. The values that are extracted are read into array s(each value in a row seperated by a space) which will be used later in a bash script. The awk does execute but no values are printed. I am also not sure how to print in a row... (1 Reply)
Discussion started by: cmccabe
1 Replies
LEARN ABOUT PHP
mongocollection.findone
MONGOCOLLECTION.FINDONE(3) 1 MONGOCOLLECTION.FINDONE(3)MongoCollection::findOne - Queries this collection, returning a single element
SYNOPSIS
public array MongoCollection::findOne ([array $query = array()], [array $fields = array()], [array $options = array()])
DESCRIPTION
As opposed to MongoCollection.find(3), this method will return only the first result from the result set, and not a MongoCursor that can
be iterated over.
PARAMETERS
o $query
- The fields for which to search. MongoDB's query language is quite extensive. The PHP driver will in almost all cases pass the
query straight through to the server, so reading the MongoDB core docs on find is a good idea.
Warning
Please make sure that for all special query operaters (starting with $) you use single quotes so that PHP doesn't try to
replace "$exists" with the value of the variable $exists.
o $fields
- Fields of the results to return. The array is in the format array('fieldname' => true, 'fieldname2' => true). The _id field is
always returned.
o $options
- This parameter is an associative array of the form array("name" => <value>, ...). Currently supported options are:
o "maxTimeMS"Specifies a cumulative time limit in milliseconds for processing the operation (does not include idle time). If
the operation is not completed within the timeout period, a MongoExecutionTimeoutException will be thrown.
RETURN VALUES
Returns record matching the search or NULL.
ERRORS /EXCEPTIONS
Throws MongoConnectionException if it cannot reach the database.
CHANGELOG
+--------+------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+------------------------------------+
| 1.5.0 | |
| | |
| | Added optional $options argument. |
| | |
+--------+------------------------------------+
EXAMPLES
Example #1
MongoCollection::findOne document by its id.
This example demonstrates how to find a single document in a collection by its id.
<?php
$articles = $mongo->my_db->articles;
$article = $articles->findOne(array('_id' => new MongoId('47cc67093475061e3d9536d2')));
?>
Example #2
MongoCollection::findOne document by some condition.
This example demonstrates how to find a single document in a collection by some condition and limiting the returned fields.
<?php
$users = $mongo->my_db->users;
$user = $users->findOne(array('username' => 'jwage'), array('password'));
print_r($user);
?>
The above example will output something similar to:
Array
(
[_id] => MongoId Object
(
)
[password] => test
)
Notice how even though the document does have a username field, we limited the results to only contain the password field.
SEE ALSO MongoCollection.find(3), MongoCollection.insert(3), MongoDB core docs on find..
PHP Documentation Group MONGOCOLLECTION.FINDONE(3)