Need help extracting data for report creation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help extracting data for report creation
# 8  
Old 07-18-2014
Right, I'm sure we all get the question.

I could help with this but I know that the scripting wizards on this forum will do this much more efficiently than me. You've posted to a really high traffic forum here so I'm sure you'll get a response shortly (now the question is clearly defined).
This User Gave Thanks to hicksd8 For This Post:
# 9  
Old 07-18-2014
Quote:
Originally Posted by hicksd8
Right, I'm sure we all get the question.

I could help with this but I know that the scripting wizards on this forum will do this much more efficiently than me. You've posted to a really high traffic forum here so I'm sure you'll get a response shortly (now the question is clearly defined).
Sorry to create the mess Smilie
# 10  
Old 07-18-2014
sdosanjh,

A few questions:-
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
  • Are all the blocks of data built in this way?
  • Is the layout of each always the same?
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.


Perhaps something with grep would be appropriate. You may need a two step process though, one to extract all "insert_job" & "owner" records, and another to select just those for the specified owner.

Different OS and versions have different flags for grep, awk etc., so it's important to know which you have.


Thanks, in advance,
Robin
Lancashire, UK
# 11  
Old 07-18-2014
I tried
Code:
egrep "insert_job|owner: autosys"

but that is not working.
I have awk grep working well in the environment

Last edited by sdosanjh; 07-18-2014 at 11:03 AM..
# 12  
Old 07-18-2014
Quote:
but that is not working.
It's unclear what you mean by not working. What output/errors do you get?

You might be better with:-
Code:
egrep "^insert_job|^owner:" infile  >  outfile

Then you have two records for every job. You then need to get every occurrence of owner: autosys a read the previous line.

I did ask a number of questions. Could you answer them so we can work out the best response.



Thanks,
Robin
# 13  
Old 07-18-2014
@rbatte1,
there are no errors; but output is not as per my requirement.
i tried
Code:
 egrep "insert_job|owner: autosys"

; but i am getting all the jobs that are without owner:autosys also. because of OR operator in egrep.

While my requirement is to list only those jobs that are with owner: autosys .

---------- Post updated at 06:47 AM ---------- Previous update was at 06:45 AM ----------

ok Let me please rephrase the requirement.

1. i have file /tmp/a.txt with following entries as an example.

Code:
insert_job: job_A   job_type: c
command: echo "this is test"
machine: abc
owner: autosys
permission: gx,wx
date_conditions: 1
days_of_week: all
start_times: "18:00, 08:00"
alarm_if_fail: 1
timezone: UTC

2. Now i want output as below. (i want those jobs that has owner as autosys only
the output should be
Code:
insert_job: job_A   job_type: c
owner: autosys

# 14  
Old 07-18-2014
If you are getting all the records for both owner that you want and others, then that's a first step. This is why I described it as a two step process. Pass that output into a second grep with appropriate flags and see what you can generate.

Have a read of the manual page for grep and see if you have either the -p flag, or -A & -B as these will probably help you. Not all OSs and versions support all flags, hence why I asked for the details I did.

I do not wish to be rude, but please answer my questions so that we can help you.



Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extracting data

I have a txt file of the following format >ab_ qwerty >rt_ hfjkil >Ty2 hglashglkasghkf; >P2 aklhfklflkkgfgkfl >ui_ vnllkdskkkffkfkkf >we32 vksksjksj;lslsf'sk's's .... ..... I want to split this big file based on the header (>) (5 Replies)
Discussion started by: Lucky Ali
5 Replies

2. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

3. Shell Programming and Scripting

Test data creation

Hi, I need to produce A LOT of test data for a testing environment I've been told to look after. Should have stayed at home this week As it is for testing and probable sending to vendors I can't use real data (customer details). My wish list to Sanata is to have a number of flat files that... (1 Reply)
Discussion started by: nhatch
1 Replies

4. Shell Programming and Scripting

data in file while creation

I want to add some starting information in a file while creation. like if I type vi test.sh then #!/bin/bash will be added automatically. Somebody suggest me how to do this ?? (1 Reply)
Discussion started by: lipun4u
1 Replies

5. Shell Programming and Scripting

Extraction of data from multiple text files, and creation of a chart

Hello dear friends, My problem as explained below seems really basic. Fact is that I'm totally new to programming, and have only a week to produce a script ( CShell or Perl ? ) to perform this action. While searching on the forums, I found a command that could help me, but I don't know... (2 Replies)
Discussion started by: ackheron
2 Replies

6. Shell Programming and Scripting

Help with Creation of Script to Input Separators in Data

Hi all, I have one problem that is preparing datas so I can run a script to extrat informations for my statistic reports. I receive some datas, that are informations mixed and I need to separate them to analyse. This is an exemple of datas:... (8 Replies)
Discussion started by: Alexis Duarte
8 Replies

7. Shell Programming and Scripting

Awk Help for extracting report from logs

Hi I have a log file, with lines of following kind. ------------------------ 2009-05-15 07:49:42,574 INFO - SqlMapObjectDataDao - select - selectObject - 2 ms 2009-05-15 07:49:42,575 INFO - SqlMapUserDao - select - getUserSystemAdminSuperGroup - 0 ms 2009-05-15 07:49:42,576 INFO -... (3 Replies)
Discussion started by: jitendriya.dash
3 Replies

8. Shell Programming and Scripting

Creation of script,if the data file have more than one entry!!!

1.Daily there will be 14 files in the data directory 2.someday's the 14 files receive more than once r twice with different time stamps....we need to chk the count of the file and if the count of the file is two.we need to combine the both the files. 3. if any duplicate data is there just... (1 Reply)
Discussion started by: bobprabhu
1 Replies

9. UNIX for Dummies Questions & Answers

How to get a data creation file

Hi, I've two machine A and B. On the machine B there's a script that get with an ftp command a file on the A machine. I want that creation data file on the machine B is the creation data file on the machine A. Example: File text.txt on machine A created on 01/01/2006 11:00. The script on the... (2 Replies)
Discussion started by: superfabius
2 Replies

10. UNIX for Advanced & Expert Users

Get data creation file

Hi, I've two machine A and B. On the machine B there's a script that get with an ftp command a file on the A machine. I want that creation data file on the machine B is the creation data file on the machine A. Example: File text.txt on machine A created on 01/01/2006 11:00. The script on the... (1 Reply)
Discussion started by: superfabius
1 Replies
Login or Register to Ask a Question