01-09-2016
What exactly do you expect
- grep -n "${id}" getCSV.txt (note: id is an array)
- printf ${id[$i] & ${result[$i]}} (note: result is not an array)
to do?
That printf 's format specifier is missing...
Where is the if for the existing fi ?
This User Gave Thanks to RudiC For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all
I have two files X.txt and Y.txt. Both file contains same number of sentences. The content of X.txt is
The filter described above may be combined.
and the content of Y.txt is
The filter describ+ed above may be combin+ed.
Some of the words are separated with "+"... (2 Replies)
Discussion started by: my_Perl
2 Replies
2. Shell Programming and Scripting
I am trying to sort the following files from folder Bag to Apple, Cat Food, Dog Food. I can get all of the files I want into a new folder, but not sure of the best approch to get them to their final directory
My Files
==========
apple.1234.ext
apple.1235.ext
cat food 101.ext
Cat Food... (2 Replies)
Discussion started by: mtschroeder
2 Replies
3. UNIX for Dummies Questions & Answers
Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file.
For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt
I tried with grep -A but it's not supported on my system.
I tried with awk,... (4 Replies)
Discussion started by: eurouno
4 Replies
4. Shell Programming and Scripting
Hi Forum:
I have struggle with it and decide to use my eye ball to accomplish this.
Basically I am looking for sequence of date inside a file.
If one of the sequence repeat 2-3 time or skip once; it's still consider a match.
input text file:
Sep 6 A
Sep 6 A
Sep 10 A
Sep 7 B
Sep 8... (7 Replies)
Discussion started by: chirish
7 Replies
5. Shell Programming and Scripting
Hi Friends,
I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving...
File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies
6. Shell Programming and Scripting
not getting anywhere with this
an xml file contains multiple clients set up with same tags, different values.
I need to parse the file for client foo, and change the value of tag "64bit" from false to true.
cat clients.xml
<Client type"FIX">
<ClientName>foo</ClientName>... (3 Replies)
Discussion started by: jack.bauer
3 Replies
7. Shell Programming and Scripting
I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output.
$1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies
8. Shell Programming and Scripting
In the below bash I am trying to rename eachof the 3 text files in /home/cmccabe/Desktop/percent by matching the numerical portion of each file to lines 3,4, or 5 in /home/cmccabe/Desktop/analysis.txt. There will always be a match between the files. When a match is found each text file in... (2 Replies)
Discussion started by: cmccabe
2 Replies
9. Shell Programming and Scripting
Having a little trouble getting this to work just right.
I have xml files that i want to split some data.
I have 2 <name> tags within the file
I would like to take only the first tag and split the data.
tag example.
From this.
TAB<Name>smith, john</Name>
to
TAB<Name>smith,... (8 Replies)
Discussion started by: whegra
8 Replies
10. Shell Programming and Scripting
hi all,
trying this using shell/bash with sed/awk/grep
I have two files, one containing one column, the other containing multiple columns (comma delimited).
file1.txt
abc12345
def12345
ghi54321
...
file2.txt
abc1,text1,texta
abc,text2,textb
def123,text3,textc
gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
LEARN ABOUT PHP
maxdb_fetch_array
MAXDB_FETCH_ARRAY(3) 1 MAXDB_FETCH_ARRAY(3)
maxdb_fetch_array - Fetch a result row as an associative, a numeric array, or both
Procedural style
SYNOPSIS
mixed maxdb_fetch_array (resource $result, [int $resulttype])
DESCRIPTION
Object oriented style
mixed maxdb_result::fetch_array ([int $resulttype])
Returns an array that corresponds to the fetched row or NULL if there are no more rows for the resultset represented by the $result param-
eter.
maxdb_fetch_array(3) is an extended version of the maxdb_fetch_row(3) function. In addition to storing the data in the numeric indices of
the result array, the maxdb_fetch_array(3) function can also store the data in associative indices, using the field names of the result set
as keys.
Note
Field names returned by this function are case-sensitive.
Note
This function sets NULL fields to the PHP NULL value.
If two or more columns of the result have the same field names, the last column will take precedence and overwrite the earlier data. In
order to access multiple columns with the same name, the numerically indexed version of the row must be used.
The optional second argument $resulttype is a constant indicating what type of array should be produced from the current row data. The
possible values for this parameter are the constants MAXDB_ASSOC, MAXDB_ASSOC_UPPER, MAXDB_ASSOC_LOWER, MAXDB_NUM, or MAXDB_BOTH. By
default the maxdb_fetch_array(3) function will assume MAXDB_BOTH, which is a combination of MAXDB_NUM and MAXDB_ASSOC for this parameter.
By using the MAXDB_ASSOC constant this function will behave identically to the maxdb_fetch_assoc(3), while MAXDB_NUM will behave identi-
cally to the maxdb_fetch_row(3) function. The final option MAXDB_BOTH will create a single array with the attributes of both.
By using the MAXDB_ASSOC_UPPER constant, the behaviour of this function is identical to the use of MAXDB_ASSOC except the array index of a
column is the fieldname in upper case.
By using the MAXDB_ASSOC_LOWER constant, the behaviour of this function is identical to the use of MAXDB_ASSOC except the array index of a
column is the fieldname in lower case.
RETURN VALUES
Returns an array that corresponds to the fetched row or NULL if there are no more rows in resultset.
EXAMPLES
Example #1
Object oriented style
<?php
$maxdb = new maxdb("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s
", maxdb_connect_error());
exit();
}
$query = "SELECT name, state FROM hotel.city ORDER by zip";
$result = $maxdb->query($query);
/* numeric array */
$row = $result->fetch_array(MAXDB_NUM);
printf ("%s (%s)
", $row[0], $row[1]);
/* associative array */
$row = $result->fetch_array(MAXDB_ASSOC);
printf ("%s (%s)
", $row["NAME"], $row["STATE"]);
/* associative and numeric array */
$row = $result->fetch_array(MAXDB_BOTH);
printf ("%s (%s)
", $row[0], $row["STATE"]);
/* free result set */
$result->close();
/* close connection */
$maxdb->close();
?>
Example #2
Procedural style
<?php
$link = maxdb_connect("localhost", "MONA", "RED", "DEMODB");
/* check connection */
if (maxdb_connect_errno()) {
printf("Connect failed: %s
", maxdb_connect_error());
exit();
}
$query = "SELECT name, state FROM hotel.city ORDER by zip";
$result = maxdb_query($link, $query);
/* numeric array */
$row = maxdb_fetch_array($result, MAXDB_NUM);
printf ("%s (%s)
", $row[0], $row[1]);
/* associative array */
$row = maxdb_fetch_array($result, MAXDB_ASSOC);
printf ("%s (%s)
", $row["NAME"], $row["STATE"]);
/* associative and numeric array */
$row = maxdb_fetch_array($result, MAXDB_BOTH);
printf ("%s (%s)
", $row[0], $row["STATE"]);
/* free result set */
maxdb_free_result($result);
/* close connection */
maxdb_close($link);
?>
The above example will output something similar to:
New York (NY)
New York (NY)
Long Island (NY)
SEE ALSO
maxdb_fetch_assoc(3), maxdb_fetch_row(3), maxdb_fetch_resource(3).
PHP Documentation Group MAXDB_FETCH_ARRAY(3)