Sponsored Content
Top Forums Shell Programming and Scripting oneliner:sing SED on a specific column Post 302214848 by zaxxon on Tuesday 15th of July 2008 04:40:30 AM
Old 07-15-2008
This sufficient?

Code:
echo "mv /prod/system/system.db2 /prod/system/system.db2"| sed 's!\/prod\/!\/devl\/!2'
mv /prod/system/system.db2 /devl/system/system.db2

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert a text from a specific row into a specific column using SED or AWK

Hi, I am having trouble converting a text file. I have been working for this whole day now, still i couldn't make it. Here is how the text file looks: _______________________________________________________ DEVICE STATUS INFORMATION FOR LOCATION 1: OPER STATES: Disabled E:Enabled ... (5 Replies)
Discussion started by: Issemael
5 Replies

2. Shell Programming and Scripting

Paste value at specific column using sed

Hi I want to paste some value at specific column in a file using sed. say I want to add "Welcome to UNIX" from column 300 onwards in a file using sed. How to do it . ---------- Post updated at 11:18 AM ---------- Previous update was at 11:09 AM ---------- Adding more information : I... (14 Replies)
Discussion started by: dashing201
14 Replies

3. Shell Programming and Scripting

Can sed be used to insert data at specific column?

I'm trying to use sed to insert data at a specific column, let's say my data looks like this: 0553 1828 0552 1829 0550 1829 0549 1830 0548 1831 what I want is this: timein 0553 timeout 1828 timein 0552 timeout 1829 timein 0550 timeout 1829 timein 0549 timeout 1830 timein 0548... (5 Replies)
Discussion started by: mswartz
5 Replies

4. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

5. UNIX for Dummies Questions & Answers

deleteing duplicate lines sing uniq while ignoring a column

I have a data set that has 4 columns, I want to know if I can delete duplicate lines while ignoring one of the columns, for example 10 chr1 ASF 30 15 chr1 ASF 20 5 chr1 ASF 30 6 chr2 EBC 15 4 chr2 EBC 30 ... I want to know if I can delete duplicate lines while ignoring column 1, so the... (5 Replies)
Discussion started by: japaneseguitars
5 Replies

6. UNIX for Dummies Questions & Answers

Use sed to replace but only in a specific column of the text file

Hi, I would like to use sed to replace NA to x ('s/NA/x/g'), but only in the 5th column of the space delimited text file, nowhere else. How do I go about doing that? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

7. UNIX for Dummies Questions & Answers

Excluding a specific column from sed replacement

Hi, I would like to replace all 0's to 1's throughout my text file. However I do not want column 3 altered. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

8. Shell Programming and Scripting

awk or sed to find specific column from different files

Hi everybody, I have a folder with many files: Files with 8 columns: X 123 A B C D E F And files with 7 columns: X1234 A B C D E F I am trying to find a way to extract the 5th column when the files have eight columns, or the 4th column when the files have... (3 Replies)
Discussion started by: Tzole
3 Replies

9. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies

10. Shell Programming and Scripting

sed or awk to remove specific column to one range

I need to remove specific column to one range source file 3 1 000123456 2 2 000123569 3 3 000123564 12 000123156 15 000125648 128 000125648 Output required 3 000123456 2 000123569 3 000123564 12 000123156 15 000125648 128 000125648 (6 Replies)
Discussion started by: ranjancom2000
6 Replies
DB2_EXECUTE(3)								 1							    DB2_EXECUTE(3)

db2_execute - Executes a prepared SQL statement

SYNOPSIS
bool db2_execute (resource $stmt, [array $parameters]) DESCRIPTION
db2_execute(3) executes an SQL statement that was prepared by db2_prepare(3). If the SQL statement returns a result set, for example, a SELECT statement or a CALL to a stored procedure that returns one or more result sets, you can retrieve a row as an array from the stmt resource using db2_fetch_assoc(3), db2_fetch_both(3), or db2_fetch_array(3). Alter- natively, you can use db2_fetch_row(3) to move the result set pointer to the next row and fetch a column at a time from that row with db2_result(3). Refer to db2_prepare(3) for a brief discussion of the advantages of using db2_prepare(3) and db2_execute(3) rather than db2_exec(3). PARAMETERS
o $stmt - A prepared statement returned from db2_prepare(3). o $parameters - An array of input parameters matching any parameter markers contained in the prepared statement. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Preparing and executing an SQL statement with parameter markers The following example prepares an INSERT statement that accepts four parameter markers, then iterates over an array of arrays con- taining the input values to be passed to db2_execute(3). <?php $pet = array(0, 'cat', 'Pook', 3.2); $insert = 'INSERT INTO animals (id, breed, name, weight) VALUES (?, ?, ?, ?)'; $stmt = db2_prepare($conn, $insert); if ($stmt) { $result = db2_execute($stmt, $pet); if ($result) { print "Successfully added new pet."; } } ?> The above example will output: Successfully added new pet. Example #2 Calling a stored procedure with an OUT parameter The following example prepares a CALL statement that accepts one parameter marker representing an OUT parameter, binds the PHP variable $my_pets to the parameter using db2_bind_param(3), then issues db2_execute(3) to execute the CALL statement. After the CALL to the stored procedure has been made, the value of $num_pets changes to reflect the value returned by the stored procedure for that OUT parameter. <?php $num_pets = 0; $res = db2_prepare($conn, "CALL count_my_pets(?)"); $rc = db2_bind_param($res, 1, "num_pets", DB2_PARAM_OUT); $rc = db2_execute($res); print "I have $num_pets pets!"; ?> The above example will output: I have 7 pets! Example #3 Returning XML data as an SQL ResultSet The following example demonstrates how to work with documents stored in a XML column using the SAMPLE database. Using some pretty simple SQL/XML, this example returns some of the nodes in a XML document in an SQL ResultSet format that most users are familiar with. <?php $conn = db2_connect("SAMPLE", "db2inst1", "ibmdb2"); $query = 'SELECT * FROM XMLTABLE( XMLNAMESPACES (DEFAULT 'http://posample.org'), 'db2-fn:xmlcolumn("CUSTOMER.INFO")/customerinfo' COLUMNS "CID" VARCHAR (50) PATH '@Cid', "NAME" VARCHAR (50) PATH 'name', "PHONE" VARCHAR (50) PATH 'phone [ @type = "work"]' ) AS T WHERE NAME = ? '; $stmt = db2_prepare($conn, $query); $name = 'Kathy Smith'; if ($stmt) { db2_bind_param($stmt, 1, "name", DB2_PARAM_IN); db2_execute($stmt); while($row = db2_fetch_object($stmt)){ printf("$row->CID $row->NAME $row->PHONE "); } } db2_close($conn); ?> The above example will output: 1000 Kathy Smith 416-555-1358 1001 Kathy Smith 905-555-7258 Example #4 Performing a "JOIN" with XML data The following example works with documents stored in 2 different XML columns in the SAMPLE database. It creates 2 temporary tables from the XML documents from 2 different columns and returns an SQL ResultSet with information regarding shipping status for the cus- tomer. <?php $conn = db2_connect("SAMPLE", "db2inst1", "ibmdb2"); $query = ' SELECT A.CID, A.NAME, A.PHONE, C.PONUM, C.STATUS FROM XMLTABLE( XMLNAMESPACES (DEFAULT 'http://posample.org'), 'db2-fn:xmlcolumn("CUSTOMER.INFO")/customerinfo' COLUMNS "CID" BIGINT PATH '@Cid', "NAME" VARCHAR (50) PATH 'name', "PHONE" VARCHAR (50) PATH 'phone [ @type = "work"]' ) as A, PURCHASEORDER AS B, XMLTABLE ( XMLNAMESPACES (DEFAULT 'http://posample.org'), 'db2-fn:xmlcolumn("PURCHASEORDER.PORDER")/PurchaseOrder' COLUMNS "PONUM" BIGINT PATH '@PoNum', "STATUS" VARCHAR (50) PATH '@Status' ) as C WHERE A.CID = B.CUSTID AND B.POID = C.PONUM AND A.NAME = ? $stmt = db2_prepare($conn, $query); $name = 'Kathy Smith'; if ($stmt) { db2_bind_param($stmt, 1, "name", DB2_PARAM_IN); db2_execute($stmt); while($row = db2_fetch_object($stmt)){ printf("$row->CID $row->NAME $row->PHONE $row->PONUM $row->STATUS "); } } db2_close($conn); ?> The above example will output: 1001 Kathy Smith 905-555-7258 5002 Shipped Example #5 Returning SQL data as part of a larger XML document The following example works with a portion of the PRODUCT.DESCRIPTION documents in the SAMPLE database. It creates a XML document containing product description (XML data) and pricing info (SQL data). <?php $conn = db2_connect("SAMPLE", "db2inst1", "ibmdb2"); $query = ' SELECT XMLSERIALIZE( XMLQUERY(' declare boundary-space strip; declare default element namespace "http://posample.org"; <promoList> { for $prod in $doc/product where $prod/description/price < 10.00 order by $prod/description/price ascending return( <promoitem> { $prod, <startdate> {$start} </startdate>, <enddate> {$end} </enddate>, <promoprice> {$promo} </promoprice> } </promoitem> ) } </promoList> ' passing by ref DESCRIPTION AS "doc", PROMOSTART as "start", PROMOEND as "end", PROMOPRICE as "promo" RETURNING SEQUENCE) AS CLOB (32000)) AS NEW_PRODUCT_INFO FROM PRODUCT WHERE PID = ? $stmt = db2_prepare($conn, $query); $pid = "100-100-01"; if ($stmt) { db2_bind_param($stmt, 1, "pid", DB2_PARAM_IN); db2_execute($stmt); while($row = db2_fetch_array($stmt)){ printf("$row[0] "); } } db2_close($conn); ?> The above example will output: <promoList xmlns="http://posample.org"> <promoitem> <product pid="100-100-01"> <description> <name>Snow Shovel, Basic 22 inch</name> <details>Basic Snow Shovel, 22 inches wide, straight handle with D-Grip</details> <price>9.99</price> <weight>1 kg</weight> </description> </product> <startdate>2004-11-19</startdate> <enddate>2004-12-19</enddate> <promoprice>7.25</promoprice> </promoitem> </promoList> SEE ALSO
db2_exec(3), db2_fetch_array(3), db2_fetch_assoc(3), db2_fetch_both(3), db2_fetch_row(3), db2_prepare(3), db2_result(3). PHP Documentation Group DB2_EXECUTE(3)
All times are GMT -4. The time now is 10:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy