Fetch data from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fetch data from file
# 1  
Old 08-01-2017
Fetch data from file

Hi,

I am new to scripting. I have a log file and need to fetch specific logs and copy to another file.
A copy of the log is like this:

Code:
===============================================================
= JOB       : server123#jobs1[(0600 08/01/17),(0AAAAAAAAAACA3LL)].jobstream1
= USER      : andyc            
= Tue 08/01/17 06:01:02 CDT
===============================================================
TWS for UNIX/JOBMANRC 8.5.1

Tivoli Workload Scheduler (UNIX)/JOBINFO 8.5.1 (20091127)
Installed for user "andyc".
Locale LANG set to the following: "en"
Removes files and directories older than -32.
AWSBIS308I End of job
===============================================================
= Exit Status           : 0
= System Time (Seconds) : 0     Elapsed Time (Minutes) : 0
= User Time (Seconds)   : 0
= Tue 08/01/17 06:01:02 CDT
===============================================================

Now, I need output from first, second, third and last four lines. The lines in the log file are not fixed. And the format I need is like:

Code:
Server name: server123 | job: jobs1 | jobstream: jobstream1 | Start Time: Tue 08/01/17 06:01:02 CDT | Exit Status: 0 | Time consumed: 0

Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, output, and code segments.

Last edited by Don Cragun; 08-01-2017 at 04:01 PM.. Reason: Add CODE tags.
# 2  
Old 08-01-2017
Welcome to the forum.

Any attempts / ideas / thoughts from your side?

Please be aware that the start time cannot be identified unambiguously from your data - so which time stamp to extract? And, is the assumption correct that "Time consumed" is "System time"?
# 3  
Old 08-02-2017
Hi RudiC,
My bad, didn't clarified earlier:
Start Time to be captured from Line 4
Time Consumed: Elasped time

I tried awk command but didn't got desired output after several attempts.
# 4  
Old 08-02-2017
Quote:
Originally Posted by Prngp
Hi RudiC,
My bad, didn't clarified earlier:
Start Time to be captured from Line 4
Time Consumed: Elasped time

I tried awk command but didn't got desired output after several attempts.
Please show us the awk code that you tried so we can help you find out where you got stuck.

With Tivoli and UNIX in your sample data, we might guess that you're using AIX and ksh, but when posting questions about using common utilities on BSD, Linux, and UNIX systems it is always a good idea to tell us explicitly what operating system and shell you're using.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to fetch specific data from a file.?

Hi , I have a file which contains 2 days logs(here it is 24 and 25) I want to list data only for date 25 fron the file. please suggest me how should i get this. file content mentioned below 17-05-24 Name Succ Fail 00:00:29 ... (5 Replies)
Discussion started by: scriptor
5 Replies

2. Shell Programming and Scripting

Help Need to fetch the required data

Hi Guys, Am in need of your help one more time on my real data. I have a file which contains more than thousand lines of data Live data shown for 4 iterations. We have more than thousand lines of data:- -------------------------------------------------------------------------- ... (4 Replies)
Discussion started by: rocky2013
4 Replies

3. Shell Programming and Scripting

Fetch Data from File using UNIX or Perl

Hello, How All are Doing today. I have a issue, I have a file which contains the data as follow <ENVELOPE><ENVELOPE_ID>TEST</ENVELOPE_ID><ENVELOPE_EXTERNAL_ID></ENVELOPE_EXTERNAL_ID><ENVELOPE_VERSION>2</ENVELOPE_VERSION><SIResourceDefaultVersion>true</SIResourceDefaultVersion><TYPE>GS... (1 Reply)
Discussion started by: adisky123
1 Replies

4. UNIX for Dummies Questions & Answers

how to fetch data in unix

Hi All, I have a file with the below data as shown. A|2|20120430 B|EMP|NAME|DEPT C|12|SARC|01 C|23||ASDD|02 D|END OF FILE I want to fetch only the records that contains C|, what is unix command to fetch this data. Thanks (5 Replies)
Discussion started by: halpavan2
5 Replies

5. Shell Programming and Scripting

Fetch data between two dates from a file

Hi All, I m new to this forum & UNix too. currently i have a requirement which can fetch data from a logfile between two dates or timestamp. for example: 1. data from 2012 Jun to 2012 Jul 2. data from 2012 Jun to 2012 Jul 07 3. data from 2012 Jun 16 10:20 to 2012 Jul 03 10:10 Please... (7 Replies)
Discussion started by: KDMishra
7 Replies

6. Shell Programming and Scripting

Fetch data from a particular location

I want to fetch value from a particular location from a file but in each line in the file it appears at a different position so i tried using variable with cut command but it is not working properly. The code i have written is #!/bin/sh cat Sri1.log | while read d2 do grep -w... (9 Replies)
Discussion started by: Prachi Gupta
9 Replies

7. Shell Programming and Scripting

Fetch the different data by searching with a same variable from a file in AIX server

Hi, I am trying to fetch the different values in an xml file by searching with the same variable in AIX Server. <name>SharedResources/Shared/JNDI/Username</name> <value>admin</value> <name>SharedResources/Shared/JNDI/Username</name> ... (1 Reply)
Discussion started by: tejastrikez
1 Replies

8. Shell Programming and Scripting

How to fetch data between two timestamps in a file using KSH

Hi, I got a requirement to fetch data between two time stamps in a big log file and grep for a word in that particular time interval of data. Here is my log looks like: 2012/04/08-14:35:56 Abcdefg 2012/04/08-14:35:56 Hijklmnophhoishfw 2012/04/08-14:35:56... (1 Reply)
Discussion started by: siri_886
1 Replies

9. Shell Programming and Scripting

How to sca a sequential file and fetch some substring data from it

Hi, I have a task where i need to scan second column of seuential file and fetch first 3 digits of that column For e.g. FOLLOWING IS THE SAMPLE FOR MY SEQUENTIAL FILE AU_ID ACCT_NUM CRNCY_CDE THHSBC001 30045678 THB THHSBC001 10154267 THB THHSBC001 ... (2 Replies)
Discussion started by: manmeet
2 Replies

10. Shell Programming and Scripting

How to fetch data from a text file in Unix

I want to fetch passwords from a common file xxxx.txt and use it in a script. Currently the password is hardcoded so this have to be changed so that password can be fetched from text file..... Please reply asap.. Thanks (4 Replies)
Discussion started by: shikhakaul
4 Replies
Login or Register to Ask a Question