format a file to this output


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting format a file to this output
# 1  
Data format a file to this output

hi

i need some help over here.. please help

i have a log file as per below
Code:
---------------------------------------------------------------------------------------------------------
JOB START DATE     : 20110510204513
JOB ID             : us2cap3ds9
-------------------------------------------------------------------------
Entering Post Processes...
LOG DIRECTORY    : /batch_dir/batch/us2cap3ds9/log
JOB PID          :
JOB END DATE     : 20110510205141
Job Exit Code    : 1
-------------------------------------------------------------------------
Process completed with WARNING[s].
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
Job directory found!
Job Ini File for this job: /apps_dir/arbor/custom/conf/abc_us2cap3ds9.ini
Bypassing the App INI file. (/apps_dir/arbor/custom/conf/abc_fn_us2cap3ds9.ini)
Running Job in MULTI STREAM mode.

---------------------------------------------------------------------------------------------------------
JOB START DATE     : 20110510214512
JOB ID             : us2cap3ds9
-------------------------------------------------------------------------
Entering Post Processes...
LOG DIRECTORY    : /batch_dir/batch/us2cap3ds9/log
JOB PID          :
JOB END DATE     : 20110510215224
Job Exit Code    : 1
-------------------------------------------------------------------------
Process completed with WARNING[s].
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
Job directory found!
Job Ini File for this job: /apps_dir/arbor/custom/conf/abc_us2cap3ds9.ini
Bypassing the App INI file. (/apps_dir/arbor/custom/conf/abc_fn_us2cap3ds9.ini)
Running Job in MULTI STREAM mode.

---------------------------------------------------------------------------------------------------------
JOB START DATE     : 20110510224512
JOB ID             : us2cap3ds9
-------------------------------------------------------------------------
Entering Post Processes...
LOG DIRECTORY    : /batch_dir/batch/us2cap3ds9/log
JOB PID          :
JOB END DATE     : 20110510225230
Job Exit Code    : 1
-------------------------------------------------------------------------
Process completed with WARNING[s].
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
Job directory found!
Job Ini File for this job: /apps_dir/arbor/custom/conf/abc_us2cap3ds9.ini
Bypassing the App INI file. (/apps_dir/arbor/custom/conf/abc_fn_us2cap3ds9.ini)
Running Job in MULTI STREAM mode.

---------------------------------------------------------------------------------------------------------
JOB START DATE     : 20110510234513
JOB ID             : us2cap3ds9
-------------------------------------------------------------------------
Entering Post Processes...
LOG DIRECTORY    : /batch_dir/batch/us2cap3ds9/log
JOB PID          :
JOB END DATE     : 20110510235047
Job Exit Code    : 1
-------------------------------------------------------------------------
Process completed with WARNING[s].
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
Job directory found!
Job Ini File for this job: /apps_dir/arbor/custom/conf/abc_us2cap3ds9.ini
Bypassing the App INI file. (/apps_dir/arbor/custom/conf/abc_fn_us2cap3ds9.ini)
Running Job in MULTI STREAM mode.

---------------------------------------------------------------------------------------------------------
JOB START DATE     : 20110511004511
JOB ID             : us2cap3ds9
-------------------------------------------------------------------------
Entering Post Processes...
LOG DIRECTORY    : /batch_dir/batch/us2cap3ds9/log
JOB PID          :
JOB END DATE     : 20110511005000
Job Exit Code    : 1
-------------------------------------------------------------------------
Process completed with WARNING[s].
---------------------------------------------------------------------------------------------------------

what i want to do is to massage the log file to the following output
Code:
JOB START DATE          JOB END DATE
20110510204513        20110510205141
20110510214512        20110510215224
20110510214512        20110510215224

and so on.....


Last edited by Franklin52; 05-11-2011 at 04:41 AM.. Reason: Please use code tags
# 2  
Try this

Code:
 awk -F: 'BEGIN{print " JOB START DATE  JOB END DATE"}/JOB START DATE/{x=$2} /JOB END DATE/{print x" "$2}' logfile

regards,
Ahamed
# 3  
script aa.sh

output=`cat /usr/opt/autotree/joblogs/BATCH/us2cap3ds9.out | awk -F: 'BEGIN{print " JOB START DATE JOB END DATE"}/JOB START DATE/{x=$2} /JOB END DATE/{print x" "$2}'`
$output


error
aa.sh[2]: JOB: not found.

please help
# 4  
Please use code tags

Try this
Code:
output=`cat /usr/opt/autotree/joblogs/BATCH/us2cap3ds9.out | awk -F:  'BEGIN{print " JOB START DATE  JOB END DATE"}/JOB START DATE/{x=$2} /JOB  END DATE/{print x" "$2}'`
echo -e "$output"

Even if you want to put in a script, just use it like this
Code:
#!/bin/bash
 awk -F: 'BEGIN{print " JOB START DATE  JOB END DATE"}/JOB START DATE/{x=$2} /JOB END DATE/{print x" "$2}' logfile

regards,
Ahamed
# 5  
Code:
 awk 'BEGIN{print "JOB START DATE JOB END DATE"} /JOB START DATE :/{printf $NF FS}/JOB END DATE :/{print $NF}' file

# 6  
Code:
foreach $line(@file){
  if ($line =~ s/\w+\sSTART\s\w+\s:\s(\d+)/$1/) {print "Job Start Date, $1\n"; }
  if ($line =~ s/\w+\sEND\s\w+\s:\s(\d+)/$1/) {print "Job End Date, $1\n"; }
  }


Last edited by Franklin52; 05-11-2011 at 04:42 AM.. Reason: Please use code tags
# 7  
thanks for the help all... love you guys..
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #226
Difficulty: Easy
According to NetMarketShare, in September 2019 Android had less than a two-to-one lead over iOS in worldwide mobile device operating system market share.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with printing output format from a file

Hi, I need help in printing data in below format from file extensions with .dml, i have listed details below file name is test_temp.dml, location in /home/users/test01/test_temp.dml file content: sample_type= record decimal(",") test_type; date("DD-MM-YYYY")(",") test_date... (2 Replies)
Discussion started by: AAHinka
2 Replies

2. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

3. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

4. Shell Programming and Scripting

Help me to command to output file format.

Dear Master. Help me to command to out put. Ex log. "<?xml version=""1.0"" encoding=""UTF-10"" ?><anova-test-bom> <txid>17251032659</txid> <authentication> <user>admin</user> <password>Amrduoi</password> </authentication> <destination> <msisdn>1111111</msisdn> ... (2 Replies)
Discussion started by: ooilinlove
2 Replies

5. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

6. Shell Programming and Scripting

Change file output format

I have a file which has following contents usmtnz-dinfsi19 62 61 18400 18800 99.7 usmtnz-dinfsi19 62 61 18400 18800 99.7 i want the o/p to be like date (7 Replies)
Discussion started by: fugitive
7 Replies

7. Shell Programming and Scripting

format output in csv file

I am sending the output of a file to .csv file. The output should look like this: Total Customers Processed:,8 Total Customers Skipped:,0 Total Customers Added:,8 Total Customers Changed:,0 Total Policies Deleted:,0 Total Policies Failed:,0 total:,8 Now i want this output in... (1 Reply)
Discussion started by: Prashant Jain
1 Replies

8. Shell Programming and Scripting

format file output

Hi, I am trying to put a script together that allows for a command to be executed and then the output goes to a .html file. I am running the script on HPUX. I run: /var/fl/user/lmutil lmstat a c license_lic.dat > /web/results.html This saves the command to a .html file but the text is... (1 Reply)
Discussion started by: zerbitated
1 Replies

9. Shell Programming and Scripting

format the output from a file

hi , i need to format the output which is availble in a file file output is Following are the Process_Scheduler Domains running in the server Ram-pc VPORCL Following are the Application Server domains running in the server Ram-pc VPORCL01 VPORCL02 these value VPORCL,VPORCL01...... (5 Replies)
Discussion started by: becksram123
5 Replies

10. Shell Programming and Scripting

Format the output of file

hello all Script and example of file #!/bin/sh #sh gdata.sh /users/testsuite/db/appl/ DATE=`date '+20%y-%m-%d'` echo $DATE for i in ${1}/$DATE/* ; do find $i -name daily -prune -o -name run.log -print -exec grep -c ! {} \; done > test.log. The test.log contains output like this ... (9 Replies)
Discussion started by: getdpg
9 Replies

Featured Tech Videos