Sponsored Content
Top Forums Shell Programming and Scripting How to read a text file line by line and insert into a database table? Post 302920330 by JolietJake on Wednesday 8th of October 2014 07:32:54 PM
Old 10-08-2014
How to read a text file line by line and insert into a database table?

I have a test file that I want to read and insert only certain lines into the
the table based on a filter.

1. Rread the log file 12 Hours back Getdate() -12 Hours
2. Extract the following information on for lines that say "DUMP is
complete"
A. Date
B. Database Name
C. Phrase "Dump is Complete"
3 Insert three extracted data columns into a Database table
4. Perform select and output result to html and email






Code:
 
Feb 10 23:20:27 2014: Backup Server: 4.188.1.1: Database EligKeyDB: 14675188 kilobytes (86%) DUMPED.
Feb 10 23:20:54 2014: Backup Server: 4.188.1.1: Database EligKeyDB: 14841824 kilobytes (87%) DUMPED.
Feb 10 23:21:06 2014: Backup Server: 4.188.1.1: Database EligKeyDB: 14968036 kilobytes (89%) DUMPED.
Feb 10 23:21:20 2014: Backup Server: 4.188.1.1: Database EligKeyDB: 15119660 kilobytes (91%) DUMPED.
Feb 10 23:21:36 2014: Backup Server: 4.188.1.1: Database EligKeyDB: 15259614 kilobytes (94%) DUMPED.
Feb 10 23:21:48 2014: Backup Server: 3.43.1.1: Dump phase number 1 completed.
Feb 10 23:21:48 2014: Backup Server: 3.43.1.1: Dump phase number 2 completed.
Feb 10 23:21:48 2014: Backup Server: 3.43.1.1: Dump phase number 3 completed.
Feb 10 23:21:48 2014: Backup Server: 4.188.1.1: Database EligKeyDB: 15387946 kilobytes (100%) DUMPED.
Feb 10 23:21:48 2014: Backup Server: 3.42.1.1: DUMP is complete (database EligKeyDB).
Feb 10 23:21:48 2014: Backup Server: 2.23.1.1: Connection from Server CBSPRO on Host DSHSSAVWN8 with HostProcid 4688.
Feb 10 23:21:48 2014: Backup Server: 2.23.1.1: Connection from Server CBSPRO on Host DSHSSAVWN8 with HostProcid 4688.

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert text file at a certain line.

I need to insert a file called temp_impact (which has about 15 lines in it) to a file called 11.23cfg starting at line 33. I searched the forums and found the sed '34i\ test' 11.23cfg > newfile That will enter word test at the appropriate line, but i need the entire file dumped there. Any... (4 Replies)
Discussion started by: insania
4 Replies

2. Shell Programming and Scripting

Insert a line in a text file

So I need to write lines into line X of file X. I can get the file by doing: cfgnumber=$(cat -n -comm.cfg| grep -i "servicegroup_name 24x7-comunicacions") echo $cfgnumber it outputs the Line where it finds now I need to start writing something right bellow that line. thanks (10 Replies)
Discussion started by: 4scriptmoni
10 Replies

3. Shell Programming and Scripting

How to insert some constant text at beginig of each line within a text file.

Dear Folks :), I am new to UNIX scripting and I do not know how can I insert some text in the first column of a UNIX text file at command promtp. I can do this in vi editor by using this command :g/^/s//BBB_ e,g I have a file named as Test.dat and it containins below text: michal... (4 Replies)
Discussion started by: Muhammad Afzal
4 Replies

4. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

5. Web Development

INSERT data to a Database Table from a text file

If you have a text file and if you want to Insert data to your Database Table, You can do it with these queries LOAD DATA LOCAL INFILE '/path/yourTextFile.txt' INTO TABLE yourTableName FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' (0 Replies)
Discussion started by: sitex
0 Replies

6. Shell Programming and Scripting

Read text file line by line

Hi everyone, I am writing a BASH shell script that I will use to process data files. I have a text file that contains the names of the files to be processed, for example: cat filenames.txt file1 file2 file3 file4 file5 What I would like to do is set up a FOR loop within my script... (2 Replies)
Discussion started by: msb65
2 Replies

7. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

8. UNIX for Dummies Questions & Answers

Insert a line in a text file

I want to insert a line with text after the 9th line of a text file. How would I do this using sed or awk? (2 Replies)
Discussion started by: lost.identity
2 Replies

9. UNIX for Beginners Questions & Answers

Insert a line of text on nth line of a file

Hi All, I am using UNix Sun OS sun4u sparc SUNW,SPARC-Enterprise My intention is to insert a line of text after 13th line of every file inside a particular directory. While trying to do it for a single file , i am using sed sed '3 i this is the 4th line' filename sed: command garbled: 3... (5 Replies)
Discussion started by: gotamp
5 Replies

10. Shell Programming and Scripting

Shell script UNIX to read text file line by line

i have a text file as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name data_file.txt column_name file_name col1 file1 col2 file2 col3 file1 col4 file1 col5 file2 now, i would like to... (4 Replies)
Discussion started by: tester111
4 Replies
BDB.DB0(5)							AFS File Reference							BDB.DB0(5)

NAME
       bdb.DB0, bdb.DBSYS1 - Contain the Backup Database and associated log

DESCRIPTION
       The bdb.DB0 file contains the Backup Database, which records configuration information used by the AFS Backup System along with cross-
       indexed records of the tapes created and volumes dumped using the Backup System commands.

       The bdb.DBSYS1 file is a log file in which the Backup Server (buserver process) logs each database operation before performing it. When an
       operation is interrupted, the Backup Server replays the log to complete the operation.

       Both files are in binary format and reside in the /var/lib/openafs/db directory on each database server machine that runs the Backup
       Server.	When the Backup Server starts or restarts on a given machine, it establishes a connection with its peers and verifies that its
       copy of the bdb.DB0 file matches the copy on the other database server machines. If not, the Backup Servers use AFS's distributed database
       technology, Ubik, to distribute to all of the machines the copy of the database with the highest version number.

       Use the commands in the backup suite to administer the Backup Database. It is advisable to create a backup copy of the bdb.DB0 file on tape
       on a regular basis, using the UNIX tar command or another local disk backup utility.

SEE ALSO
       backup(8), backup_savedb(8), buserver(8)

COPYRIGHT
       IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved.

       This documentation is covered by the IBM Public License Version 1.0.  It was converted from HTML to POD by software written by Chas
       Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell.

OpenAFS 							    2012-03-26								BDB.DB0(5)
All times are GMT -4. The time now is 04:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy