Sponsored Content
Top Forums Shell Programming and Scripting Searching for Log / Bad file and Reading and writing to a flat file Post 302458926 by mlpathir on Saturday 2nd of October 2010 05:17:54 PM
Old 10-02-2010
Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance:

1) search for file.log and file.bad file in a directory and read them
2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file
4) concatinate each row from bad file as "Error_Description"
5) write to a output flat file record by record
6) make sure the "number of bad record count from log file = number of records written to the output flat file"
7) below are the formats of log and bad file and output file

Log File:
=========

Load started at: 1-Oct-10 11:00:00 EDT
Database: Oracle
Tablename: abc_def_123
Datafile: /abc/def/ghi/inbound/files/file.dat


Error_Type:
-------------------------------------------------
1: 123(456) [CHAR(1)] value too long for column]
2: 123(456) [CHAR(1)] value too long for column]
3: 123(456) [CHAR(1)] value too long for column]
4: 123(456) [CHAR(1)] value too long for column]

number of bad records: 4

Bad File:
========

111 456 abc 789 2010-10-1 manager US
222 456 abc 789 2010-10-1 employee US
333 456 abc 789 2010-10-1 contractor US
444 456 abc 789 2010-10-1 partner US


Output File:
===========

Load_Start_Time Data_File_Name Error_Type Error_Description
1-Oct-10 11:00:00 file.dat 1: 123(456) [CHAR(1)] value too long for column] 111 456 abc 789 2010-10-1 manager US
1-Oct-10 11:00:00 file.dat 2: 123(456) [CHAR(1)] value too long for column] 222 456 abc 789 2010-10-1 employee US
1-Oct-10 11:00:00 file.dat 3: 123(456) [CHAR(1)] value too long for column] 333 456 abc 789 2010-10-1 contractor US
1-Oct-10 11:00:00 file.dat 4: 123(456) [CHAR(1)] value too long for column] 444 456 abc 789 2010-10-1 partner US

Last edited by mlpathir; 10-02-2010 at 07:00 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Reading a file and writing the file name to a param file.

Hi All, Not sure if this would be in a dummies sectiin or advanced. I'm looking for a script if someone has doen something like this. I have list of files - adc_earnedpoints.20070630.txt adc_earnedpoints.20070707.txt adc_earnedpoints.20070714.txt adc_earnedpoints.20070721.txt... (1 Reply)
Discussion started by: thebeginer
1 Replies

2. UNIX for Dummies Questions & Answers

Log File Writing and Reading

Hi all, I have the following shell script code which tries to sftp and writes the log into the log file. TestConnection () { echo 'Connection to ' $DESTUSERNAME@$DESTHOSTNAME $SETDEBUG if ]; then rm $SCRIPT ; fi touch $SCRIPT echo "cd" $REMOTEDIR >> $SCRIPT echo "quit" >>... (10 Replies)
Discussion started by: valluvan
10 Replies

3. Programming

I need help with file reading/writing in C

Hello everybody, I'm trying to code a program which makes the following: It sends an ARP request frame and when it gets the reply, extracts the IP address of source and writes it to a .txt file. This is gonna be done with many hosts (with a for() loop), so, the text file would look like... (2 Replies)
Discussion started by: Zykl0n-B
2 Replies

4. Shell Programming and Scripting

Reading a FLAT File - No Delimeters

Hi Folks, I have a file without any delimeters and it is a flat file. Example, my raw data looks: x25abcy26defz27ghi..... Now, could you please any one help me to program to split this into variable and create a text file. I want a output as below Name Age Number x 25 abc... (14 Replies)
Discussion started by: Jerald Nathan
14 Replies

5. Shell Programming and Scripting

Reading XML data in a FLAT FILE

I have a requirement to read the xml file and split the files into two diffrent files in Unix shell script. Could anyone please help me out with this requirement. Sample file --------------- 0,<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Information... (3 Replies)
Discussion started by: kmanivan82
3 Replies

6. Shell Programming and Scripting

Remove the footer from a flat file by searching a pattern

Hi, I have more than 30,000 records in a flat file. I want to remove footer from the file by searching a string pattern for the footer. Example.... let the flat file test.dat contains below records. record1 record2 record3 .. .. .. record31000 Total records 31000 I want to remove the... (6 Replies)
Discussion started by: gani_85
6 Replies

7. Shell Programming and Scripting

reading a file extracting information writing to a file

Hi I am trying to extract information out of a file but keep getting grep cant open errors the code is below: #bash #extract orders with blank address details # # obtain the current date # set today to the current date ccyymmdd format today=`date +%c%m%d | cut -c24-31` echo... (8 Replies)
Discussion started by: Bruble
8 Replies

8. Shell Programming and Scripting

reading a csv file and creating a flat file

hi i have written a script for reading a csv file and creating a flat file, suggest if this script can be optimized #---------------- FILENAME="$1" SCRIPT=$(basename $0) #-----------------------------------------// function usage { echo "\nUSAGE: $THIS_SCRIPT file_to_process\n"... (3 Replies)
Discussion started by: mprakasheee
3 Replies

9. Shell Programming and Scripting

Reading and writing in same file

Hi All, Here is my requirement. I am grepping through the log files and cutting some fields from the file to generate a csv file. Now I have to check if 2nd field is having some fixed value then with the help of 4th field I have to look in same log and run another grep command to retrieve the... (11 Replies)
Discussion started by: kmajumder
11 Replies

10. Programming

Reading flat file content

is there any unix tools that can read the text files like through SQL queries? (ie in Hadoop, Impala DB support flat file query) (1 Reply)
Discussion started by: omykarshan
1 Replies
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 03:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy