03-07-2011
Formatting Multiple fields on 1 line to multiple rows
I'm trying extract a number of filename fields from a log file and copy them out as separate rows in a text file so i can load them into a table. I'm able to get the filenames but the all appear on one line. I tried using the cut command with the -d (delimiter) option but cant seem to make it work. Any suggestions of how to get this to work or a better way to do this would be much appreciated.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
Perhaps someone here can help with this. I'd like to grep a plain text file for a word and output each line containing a word found to a seperate line instead of back to back.
Examples:
Basic command:
cat file.txt > grep -i CAT > results.txt
file.txt:
The cat said meow
The... (7 Replies)
Discussion started by: sysera
7 Replies
2. Shell Programming and Scripting
Hello,
I have two files that I need to compare and print out the line from file2 that has the first 6 fields matching the first 6 fields in file1. Complicating this are the following restrictions
1. file1 is only a few thousand lines at most and file2 is greater than 2 million
2. I need to... (7 Replies)
Discussion started by: gillesc_mac
7 Replies
3. Shell Programming and Scripting
Hello,
I am trying to write a bash shell script that does the following:
1.Finds all *.txt files within my directory of interest
2. reads each of the files (25 files) one by one (tab-delimited format and have the same data format)
3. skips the first 10 rows of the file
4. extracts and... (4 Replies)
Discussion started by: manishabh
4 Replies
4. UNIX for Dummies Questions & Answers
Hi every one;
I have a file with 22 rows and 13 columns which includes floating numbers.
I want to parse the file so that every five columns in the row would be a new record (row). For example, the first line in the old file should be converted into three lines with first two lines contain 5... (6 Replies)
Discussion started by: PHL
6 Replies
5. Shell Programming and Scripting
I have a bash script which takes a log file with each record separated by a #. The records have multiple fields but field $1 is always the date and time. When the script is run it prints the record just fine from oldest to newest. I need to have records print out from newest first.
Here is the... (7 Replies)
Discussion started by: numele
7 Replies
6. Shell Programming and Scripting
Hi pls help me out to short out this problem
rm PAB113_011.out
rm: PAB113_011.out: override protection 644 (yes/no)? n
If i give y it remove the file.
But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (7 Replies)
Discussion started by: sri_aue
7 Replies
7. Shell Programming and Scripting
Hi,
I am trying to extract data from output files.
I have three awk commands that can be used. All the three commands works separately. The second and third are similar as it outputs 'line 3' and 'line 13' after
the common 'string' (I do not know how to combine them). I would like to get the... (4 Replies)
Discussion started by: p_sun
4 Replies
8. Shell Programming and Scripting
Hey all,
Unfortunately I have only basic knowledge of awk and/or scripting. If I have a file with lines that can look similar to this:
Name=line1 Arg1=valueA Arg2=valueB Arg3=valueC
Name=line2 Arg1=valueD
Name=line3 Arg1=valueE Arg3=valueF
Name=line4 Arg2=valueG ... (4 Replies)
Discussion started by: Rike255
4 Replies
9. Shell Programming and Scripting
Hello,
I met a challenge to extract part of the table. I'd like to grep the first three matches based on field1 and field2. Input:
D A 92.85 1315 83 11
D A 95.90 757 28 3
D A 94.38 480 20 7
D A 91.21 307 21 6
D A 94.26 244 ... (6 Replies)
Discussion started by: yifangt
6 Replies
10. Shell Programming and Scripting
Dear All,
I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File.
The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files.
Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies
PDO.EXEC(3) 1 PDO.EXEC(3)
PDO
::exec - Execute an SQL statement and return the number of affected rows
SYNOPSIS
public int PDO::exec (string $statement)
DESCRIPTION
PDO.exec(3) executes an SQL statement in a single function call, returning the number of rows affected by the statement.
PDO.exec(3) does not return results from a SELECT statement. For a SELECT statement that you only need to issue once during your program,
consider issuing PDO.query(3). For a statement that you need to issue multiple times, prepare a PDOStatement object with PDO.prepare(3) and
issue the statement with PDOStatement.execute(3).
PARAMETERS
o $statement
- The SQL statement to prepare and execute. Data inside the query should be properly escaped.
RETURN VALUES
PDO.exec(3) returns the number of rows that were modified or deleted by the SQL statement you issued. If no rows were affected, PDO.exec(3)
returns 0.
Warning
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on
Booleans for more information. Use the === operator for testing the return value of this function.
The following example incorrectly relies on the return value of PDO.exec(3), wherein a statement that affected 0 rows results in a call to
die(3):
<?php
$db->exec() or die(print_r($db->errorInfo(), true));
?>
EXAMPLES
Example #1
Issuing a DELETE statement
Count the number of rows deleted by a DELETE statement with no WHERE clause.
<?php
$dbh = new PDO('odbc:sample', 'db2inst1', 'ibmdb2');
/* Delete all rows from the FRUIT table */
$count = $dbh->exec("DELETE FROM fruit WHERE colour = 'red'");
/* Return number of rows that were deleted */
print("Deleted $count rows.
");
?>
The above example will output:
Deleted 1 rows.
SEE ALSO
PDO.prepare(3), PDO.query(3), PDOStatement.execute(3).
PHP Documentation Group PDO.EXEC(3)