Correct format in a log file

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Correct format in a log file
# 1  
Old 12-06-2007
Correct format in a log file

I'm trying to read the output of a .sql script (simple insert and commit oracle pl/slq script) to a log file using a shell script. My problem is I end up with a log file that looks like this:

sd12@phenix97:/detain/sd12/logs > cat 20071205_detain_20071206.log
12320496 rows created. Commit complete. 14439654 rows created. Commit complete. 8307988 rows created. 0 rows created. Commit complete. 0 rows created. Commit complete. 0 rows created. Commit complete. 62 rows created. Commit complete. 5013 rows created. Commit complete. 15997 rows created. Commit complete. 173 rows created. Commit complete. 0 rows created. Commit complete. 2 rows created. Commit complete. 9076 rows created. Commit complete. 716 rows created. Commit complete.

How do i get it to start a new line after Commit Complete. Is there a way I can have it do this by modifying my .sh script.

Thanks in Advance.
# 2  
Old 12-06-2007
can you show use some of the shell script??

often you cxan get a new line to start by using \n


echo "first line\nsecond line"
# 3  
Old 12-06-2007
how about awk?
awk -F'.' ' { print $0  "." } ' oraclelogfile

# 4  
Old 12-06-2007
This is the .sh script:

LFFD=`TZ=CST+24 date +%Y%m%d` #FOR_DATE
VALUE=`sqlplus -s sd12@phenix97/sd12 @detain.sql`
if [ -z "$VALUE" ]; then
echo "No Rows Copied"
exit 0
echo $VALUE >> $LF #LOG_FILE
exit 0

so, the log file reads the output from 'detain.sql' which is:

sd12@phenix97:/detain/sd12/logs > cat detain.sql | more
insert into schema.table1 (select * from schema.table1@DF_DBLINK.WORLD where for_date = to_date(trunc((sysdate)-1)));


insert into schema.table2 (select * from schema.table2@DF_DBLINK.WORLD where for_date = to_date(trunc((sysdate)-1)));

insert into schema.tablen (select * from schema.tablen@DF_DBLINK.WORLD where for_date = to_date(trunc((sysdate)-1)));



Does the /n (new line) go in b/w each insert statement? I rem'ber trying that & it didn't work. Is there a way I can include something in the .sh to make $VALUE format in the way I orig. wanted? Please Advice
# 5  
Old 12-06-2007
echo "$VALUE\n" >> $LF #LOG_FILE
# 6  
Old 12-10-2007
This def. works. Thanks rob. I still need to get rid of the blank lines in between:

0 rows created.

Commit complete.

1164988 rows created.

Commit complete.

8320999 rows created.

Commit complete.

1494097 rows created.

Commit complete.

Any ideas?
# 7  
Old 12-10-2007
echo "$VALUE" >> $LF #LOG_FILE

remvoing the extra newline character changes the doubly spaced output to single-spaced.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check user entered correct file format or not?

Hi Experts, path=/db/files/ format=$1 User can enter any file the user file format with actual file format existed in the directory /db/files. User enter all characters as "A" apart from date format. example1: user will be entering the file format AAA_AA_YYYYMMDD.AAA Actual... (6 Replies)
Discussion started by: nalu
6 Replies

2. Shell Programming and Scripting

Extract the correct format of file Name

All, Objective : Extract the correct format of a file name. Please share the script command which will extract the correct format of the file after untarring. Example : If the file is of .csv format then extract filename.csv if the file is having .CSV then extract the same.CSV if the file... (1 Reply)
Discussion started by: Mahesh G
1 Replies

3. Shell Programming and Scripting

Output not in correct format - cd script

I have a script that looks like this: dirname2=/usr/tmp/filelist/*/* for dirname2 in /tmp/filelist/*/*; do (cd $dirname2/catalog ||echo "file does not exist" && echo "$dirname2" |cut -d '/' -f 7,8 && echo $i && ls -la |awk 'NR>3 {SUM += $5} END { print "Total number of kb " SUM }');done... (2 Replies)
Discussion started by: newbie2010
2 Replies

4. Shell Programming and Scripting

Html output in correct format

Hi, I am running two scripts as below. In Script 1 i am getting correct output in proper HTML format while in script 2 i am not getting output in mail and only html code is getting printed.I want to get the output of script 2. Please guide. 1.IFILE=/home/home01/Report.csv if #Checks... (7 Replies)
Discussion started by: Vivekit82
7 Replies

5. UNIX for Dummies Questions & Answers

[Solved] Downloaded file is not correct format

Hi, Recently we migrated an application in HP UX to Linux. The files(scripts & logs)download from HP UX coming in a formatted way in MS notepad. However the files in Linux are not in correct format in MS notepad(No spaces , some spl symbols like square).We tried both ASCII and binary but no... (2 Replies)
Discussion started by: nag_sathi
2 Replies

6. Shell Programming and Scripting

How to check if date format is correct?

Hi! how do i know if the input is the same as the required date format? the date should be dd/mm/YYYY ex. 2/3/2012 or 15/11/2012 all the following conditions must return an error: *input of string *day is > 31 or < 1 *month is > 12 or < 1 *year is < 2013 suppose the date format is stored... (1 Reply)
Discussion started by: angilulu
1 Replies

7. Shell Programming and Scripting

Dates not comparing correct even the same format

I have the date of the file passed into a variable also current date formatted same passed into a separate variable and compare the two with an if statement and statement always comes up false. Even though I verified the dates. Any help would be awesome. Filecrtdate=`ls -l $i | awk '{print... (19 Replies)
Discussion started by: coderanger
19 Replies

8. Shell Programming and Scripting

Correct a pattern format using sed

hi all I have a file with many lines like aa;bb;cc;dd;ee bb;aa;dd;ee;bb cc;ee;bb;dd;aa ee;cc;bb;aa;dd . . . etc The first line is in right format,Please help me how to use "SED" to change the rest of the lines to the format like line 1 thank all! (1 Reply)
Discussion started by: yuesko
1 Replies

9. Shell Programming and Scripting

Exit if date not in correct format

Can somone take a look at this script for me - I'm trying to get it to exit if the format of dateToLookFor is not in the format YYYYMMDD: function search { cd $logsloc echo "Enter date in format YYYYMMDD (enter to exit):" read dateToLookFor echo $dateToLookFor | grep -q ... (2 Replies)
Discussion started by: rich@ardz
2 Replies

10. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies
Login or Register to Ask a Question