Sponsored Content
Top Forums Shell Programming and Scripting Reading each item from a formatted file Post 302410909 by angshuman_ag on Wednesday 7th of April 2010 06:23:55 AM
Old 04-07-2010
Quote:
Originally Posted by Jairaj
Try this :

Code:
awk '{print $2}' tempFile

Hi Jai,
That was great. It worked. Smilie Can you explain this commaned too Smilie ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing Formatted Records From A File

Hi All, I'm writing a script that provides a menu to manipulate records. I'm having a problem, however. The first option I'm writing is simply to display all of the records in a supplied file. The supplied file ('records') currently contains sample data, this data is: ... (3 Replies)
Discussion started by: Silentwolf
3 Replies

2. Shell Programming and Scripting

Searching for file and stopping at first item found

Hello, I try to write a shell script that would list all files on a directory and stop when it finds the first item specified on a find or ls command. How can I tell to the find or ls command to stop when it finds the first ".doc" file for example ? Thank you (7 Replies)
Discussion started by: davchris
7 Replies

3. Shell Programming and Scripting

Print new item in file with symbol

Dear all, I have encountered some problem here. I prompt the user for input and store it into a data file, eg. key in name and marks so the data file will look like this andrew 80 ben 75 and the next input is carine 90. So the problem here is i want to print... (2 Replies)
Discussion started by: branred
2 Replies

4. Shell Programming and Scripting

Extract information from Log file formatted

Good evening! Trying to make a shell script to parse log file and show only required information. log file has 44 fields and alot of lines, each columns separated by ":". log file is like: first_1:3:4:5:6:1:3:4:5:something:notinterested second_2:3:4:3:4:2 first_1:3:4:6:6:7:8 I am interested... (3 Replies)
Discussion started by: dummie55
3 Replies

5. Shell Programming and Scripting

Mail a formatted csv file

I have the below script i am getting the csv in garbled format.Please suggest the changes. SUNOS ####################################################################### ####MAIN SCRIPT ####################################################################### today=`date "+%m-%d-%Y ... (3 Replies)
Discussion started by: rafa_fed2
3 Replies

6. Shell Programming and Scripting

awk operation to get table formatted file

I need to parse .conf file in Unix system to get output from the snippets like below : ; generated by mod_identity exten => int,1,GoSub(mdc_template-3,s,1) exten => int,n(next_380),Return() ; default action for busy exten => ext,1,GoSub(mdc_template-3,s,1) exten => ext,n,Set(PRI_CAUSE=17)... (2 Replies)
Discussion started by: cheecky
2 Replies

7. Shell Programming and Scripting

Read a lis, find items in a file from the list, change each item

Hello, I have some tab delimited text data, file: final_temp1 aname val NAME;r'(1,) 3.28584 r'(2,)<tab> NAME;r'(3,) 6.13003 NAME;r'(4,) 4.18037 r'(5,)<tab> You can see that the data is incomplete in some cases. There is a trailing tab after the first column for each incomplete row. I... (2 Replies)
Discussion started by: LMHmedchem
2 Replies

8. UNIX for Beginners Questions & Answers

Zabbix item for last line of a log file

Dear all,Zabbix version : 2.4 (yes, I know, upgrading soon - honest) Server OS version : CentOS 6, 64-bit (CentOS 7 with the Zabbix upgrade)I've got a large log file that I would like to read by an external process. It's basically the same as reading the item value on a web-page. I have... (5 Replies)
Discussion started by: rbatte1
5 Replies

9. Shell Programming and Scripting

Processing a formatted file with awk

Hi - I want to interrogate information about my poker hands, sessions are all recorded in a text file in a particular format. Each hand starts with the string <PokerStars> followed by a unique hand reference and other data like date/time. There is then all the information about each hand. My first... (5 Replies)
Discussion started by: rbeech23
5 Replies

10. Shell Programming and Scripting

Script to process a list of items and uncomment lines with that item in a second file

Hello, I have a src code file where I need to uncomment many lines. The lines I need to uncomment look like, C CALL l_r(DESNAME,DESOUT, 'Gmax', ESH(10), NO_APP, JJ) The comment is the "C" in the first column. This needs to be deleted so that there are 6 spaces preceding "CALL".... (7 Replies)
Discussion started by: LMHmedchem
7 Replies
OCI_GET_IMPLICIT_RESULTSET(3)											     OCI_GET_IMPLICIT_RESULTSET(3)

oci_get_implicit_resultset  -  Returns	the  next  child statement resource from a parent statement resource that has Oracle Database 12c Implicit
Result Sets

SYNOPSIS
resource oci_get_implicit_resultset (resource $statement) DESCRIPTION
Used to fetch consectutive sets of query results after the execution of a stored or anonymous Oracle PL/SQL block where that block returns query results with Oracle's DBMS_SQL.RETURN_RESULT PL/SQL function. This allows PL/SQL blocks to easily return query results. The child statement can be used with any of the OCI8 fetching functions: oci_fetch(3), oci_fetch_all(3), oci_fetch_array(3), oci_fetch_object(3), oci_fetch_assoc(3) or oci_fetch_row(3) Child statements inherit their parent statement's prefetch value, or it can be explicitly set with oci_set_prefetch(3). PARAMETERS
o $statement -A valid OCI8 statement identifier created by oci_parse(3) and executed by oci_execute(3). The statement identifier may or may not be associated with a SQL statement that returns Implicit Result Sets. RETURN VALUES
Returns a statement handle for the next child statement available on $statement. Returns FALSE when child statements do not exist, or all child statements have been returned by previous calls to oci_get_implicit_resultset(3). EXAMPLES
Example #1 Fetching Implicit Result Sets in a loop <?php $conn = oci_connect('hr', 'welcome', 'localhost/pdborcl'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $sql = 'DECLARE c1 SYS_REFCURSOR; BEGIN OPEN c1 FOR SELECT city, postal_code FROM locations WHERE ROWNUM < 4 ORDER BY city; DBMS_SQL.RETURN_RESULT(c1); OPEN c1 FOR SELECT country_id FROM locations WHERE ROWNUM < 4 ORDER BY city; DBMS_SQL.RETURN_RESULT(c1); END;'; $stid = oci_parse($conn, $sql); oci_execute($stid); while (($stid_c = oci_get_implicit_resultset($stid))) { echo "<h2>New Implicit Result Set:</h2> "; echo "<table> "; while (($row = oci_fetch_array($stid_c, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { echo "<tr> "; foreach ($row as $item) { echo " <td>".($item!==null?htmlentities($item, ENT_QUOTES|ENT_SUBSTITUTE):"&nbsp;")."</td> "; } echo "</tr> "; } echo "</table> "; } // Output is: // New Implicit Result Set: // Beijing 190518 // Bern 3095 // Bombay 490231 // New Implicit Result Set: // CN // CH // IN oci_free_statement($stid); oci_close($conn); ?> Example #2 Getting child statement handles individually <?php $conn = oci_connect('hr', 'welcome', 'localhost/pdborcl'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $sql = 'DECLARE c1 SYS_REFCURSOR; BEGIN OPEN c1 FOR SELECT city, postal_code FROM locations WHERE ROWNUM < 4 ORDER BY city; DBMS_SQL.RETURN_RESULT(c1); OPEN c1 FOR SELECT country_id FROM locations WHERE ROWNUM < 4 ORDER BY city; DBMS_SQL.RETURN_RESULT(c1); END;'; $stid = oci_parse($conn, $sql); oci_execute($stid); $stid_1 = oci_get_implicit_resultset($stid); $stid_2 = oci_get_implicit_resultset($stid); $row = oci_fetch_array($stid_1, OCI_ASSOC+OCI_RETURN_NULLS); var_dump($row); $row = oci_fetch_array($stid_2, OCI_ASSOC+OCI_RETURN_NULLS); var_dump($row); $row = oci_fetch_array($stid_1, OCI_ASSOC+OCI_RETURN_NULLS); var_dump($row); $row = oci_fetch_array($stid_2, OCI_ASSOC+OCI_RETURN_NULLS); var_dump($row); // Output is: // array(2) { // ["CITY"]=> // string(7) "Beijing" // ["POSTAL_CODE"]=> // string(6) "190518" // } // array(1) { // ["COUNTRY_ID"]=> // string(2) "CN" // } // array(2) { // ["CITY"]=> // string(4) "Bern" // ["POSTAL_CODE"]=> // string(4) "3095" // } // array(1) { // ["COUNTRY_ID"]=> // string(2) "CH" // } oci_free_statement($stid); oci_close($conn); ?> Example #3 Explicitly setting the Prefetch Count <?php $conn = oci_connect('hr', 'welcome', 'localhost/pdborcl'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $sql = 'DECLARE c1 SYS_REFCURSOR; BEGIN OPEN c1 FOR SELECT city, postal_code FROM locations ORDER BY city; DBMS_SQL.RETURN_RESULT(c1); END;'; $stid = oci_parse($conn, $sql); oci_execute($stid); $stid_c = oci_get_implicit_resultset($stid); oci_set_prefetch($stid_c, 200); // Set the prefetch before fetching from the child statement echo "<table> "; while (($row = oci_fetch_array($stid_c, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { echo "<tr> "; foreach ($row as $item) { echo " <td>".($item!==null?htmlentities($item, ENT_QUOTES|ENT_SUBSTITUTE):"&nbsp;")."</td> "; } echo "</tr> "; } echo "</table> "; oci_free_statement($stid); oci_close($conn); ?> Example #4 Implicit Result Set example without using oci_get_implicit_resultset(3) All results from all queries are returned consecutively. <?php $conn = oci_connect('hr', 'welcome', 'localhost/pdborcl'); if (!$conn) { $e = oci_error(); trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR); } $sql = 'DECLARE c1 SYS_REFCURSOR; BEGIN OPEN c1 FOR SELECT city, postal_code FROM locations WHERE ROWNUM < 4 ORDER BY city; DBMS_SQL.RETURN_RESULT(c1); OPEN c1 FOR SELECT country_id FROM locations WHERE ROWNUM < 4 ORDER BY city; DBMS_SQL.RETURN_RESULT(c1); END;'; $stid = oci_parse($conn, $sql); oci_execute($stid); // Note: oci_fetch_all and oci_fetch() cannot be used in this manner echo "<table> "; while (($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { echo "<tr> "; foreach ($row as $item) { echo " <td>".($item!==null?htmlentities($item, ENT_QUOTES|ENT_SUBSTITUTE):"&nbsp;")."</td> "; } echo "</tr> "; } echo "</table> "; // Output is: // Beijing 190518 // Bern 3095 // Bombay 490231 // CN // CH // IN oci_free_statement($stid); oci_close($conn); ?> NOTES
Note For queries returning a large number of rows, performance can be significantly improved by increasing oci8.default_prefetch or using oci_set_prefetch(3). PHP Documentation Group OCI_GET_IMPLICIT_RESULTSET(3)
All times are GMT -4. The time now is 01:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy