data formatting in Unix shell Scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting data formatting in Unix shell Scripting
# 1  
Old 10-04-2008
Question data formatting in Unix shell Scripting

#! /bin/ksh
############################
# AFI Monitor Script
############################
. /db2/uszlad48/sqllib/db2profile
export mondir=/home/script/krishna
export monlog=$mondir/Error_Report_`date +%Y%m%d`.log
echo "connect to database r2pdev" >>$monlog
db2 connect to r2pdev user bmwdevup using summer08 >>$monlog
rm currenttimestamp
rm myfile
# get the current timestamp from SYSIBM.SYSDUMMY1
#echo "Run SQL select current timestamp from SYSIBM.SYSDUMMY1 with ur" >>$monlog
db2 "select current timestamp from SYSIBM.SYSDUMMY1 with ur" >> currenttimestamp
cat currenttimestamp
echo "***********"
awk 'NR==4' currenttimestamp>>myfile
editeddata="/home/bmwdev1/script/krishna"
myFile="/home/bmwdev1/script/krishna/myfile"
myData=""
myData=`cat $myFile`
echo $myData
#
# get the current timestamp from SYSIBM.SYSDUMMY1
#echo "Run SQL select * from bmwdev1.zb_rcbl_error" >>$monlog
db2 "SELECT * FROM BMWDEV1.ZB_RCBL_ERROR WHERE TIMESTAMP_UPDATED >= '2008-10-01-00.00.00.000000' AND TIMESTAMP_UPDATED < '$myData' WITH UR" >>$monlog
echo "After SQL execution" >>$monlog
exit 0
========================
When I execute above script, I am getting the output as follows in the file Error_Report_20081008.log

____________________________________________________________

connect to database r2pdev
Database Connection Information
Database server = DB2/AIX64
SQL authorization ID = TESTUP
Local database alias = TESTDB

TIMESTAMP_UPDATED USER_UPDATED ERROR_STATUS_CD HOUSEHOLD_NUM
-------------------------- ------------------------- ------------------------ -------------
2008-10-02-00.04.49.762909R2PE16887670282008-10-01-08.57.12.818426userS6270802022008-10-02-01.06.06.185314R2PE6803433642008-10-02-01.24.59.139125userS8943261622008-10-02-01.27.18.340835R2PE6652800102008-10-02-01.52.43.336056R2PE16314032512008-10-02-02.52.39.460247R2PE1631284206

7 Record(s) selected.

____________________________________________________________

I don't want all these datas. I want the data as follows.

================================================
2008-10-02-00.04.49.762909R2PE16887670282008-10-01-08.57.12.818426userS6270802022008-10-02-01.06.06.185314R2PE6803433642008-10-02-01.24.59.139125userS8943261622008-10-02-01.27.18.340835R2PE6652800102008-10-02-01.52.43.336056R2PE16314032512008-10-02-02.52.39.460247R2PE1631284206
================================================

can any one help me to fix this problem.

Krishnakanth
# 2  
Old 10-04-2008

Pipe the script through grep:

Code:
yourscript | grep '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies

2. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

3. Shell Programming and Scripting

How to extract data from XML file using shell scripting?

Hi , I have input file as XML. following are input data #complex.xml Code: <?xml version="1.0" encoding="UTF-8"?><TEST_doc xmlns="http://www.w3.org/2001/XMLSchema-instance"> <ENTRY uid="123456"> <protein> <name>PROT001</name> <organism>Human</organism> ... (1 Reply)
Discussion started by: arun_kohan
1 Replies

4. Shell Programming and Scripting

How to extract data from xml file using shell scripting?

Hi evry1, This is my 1st post in this forum.Pls help me I want to extract some data froma xml file which has 2000 lines using shell scripting. Actually my xml file has some "audio and video codes" which i need to arrange in a column wise format after extracting it using shell scripting.I... (4 Replies)
Discussion started by: arun_kohan
4 Replies

5. Shell Programming and Scripting

Help With UNIX Shell Scripting For Data Validation

Hi All, I am completely new to Unix Shell Scripting. I m validating(Basic File Validation) an .HHT file in TIBCO. After that i need to do Data Validation through UNIX Shell scripting. Rules in DataValidation: 1.) Need to Check Every field wheather it is a Char or Number?(Fields are... (1 Reply)
Discussion started by: Chaitanya K
1 Replies

6. Shell Programming and Scripting

AWK/Shell script for formatting data in a file

Hi All, Need an urgent help to convert a unix file in to a particular format: **source file:** 1111111 2d2f2h2 3dfgsd3 ........... 1111111 <-- repeats in every nth line. remaining all lines will be different 123ss41 432ff45 ........... 1111111 <-- repetition qwe1234 123weq3... (1 Reply)
Discussion started by: rajivnairfis
1 Replies

7. Shell Programming and Scripting

Extracting data from file-shell scripting--please help

hello friends, my file is like 123 |asd|asd|asd 123_1|awd|asw|asw 121 |wer|qwe|wee 124 |weq|qwe|iop 1_23 |bla|blh|bha 145 |ghj|jkl|ghj 146 |qwe|qwe|wer 154 |asd|wer|qw_e 134_5|qwe|wer|qw_e is their any solution to retrive only those lines which are having only 3 numerical letters... (20 Replies)
Discussion started by: PankajChawla
20 Replies

8. Shell Programming and Scripting

Shell scripting to extract data from file

Hi, i want to fetch the data from the alert log file, for a particular time interval. Example : Alert log content : Thu Mar 18 08:47:36 2010 Completed: alter database open Thu Mar 18 19:13:38 2010 MMNL absent for 6390 secs; Foregrounds taking over Fri Mar 19 08:30:52 2010... (1 Reply)
Discussion started by: Pinki018
1 Replies

9. UNIX for Dummies Questions & Answers

How to cut data block from .txt file in shell scripting

Hi All, Currently i have to write a script. For which i need to cut a block from .txt file. I know the specific word that starts the block and ends the block. Can we do it in shell scripting..? Please suggest.... (6 Replies)
Discussion started by: pank29
6 Replies

10. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
Login or Register to Ask a Question