need to get a portion of entries in file based on a criteria --- Help please


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users need to get a portion of entries in file based on a criteria --- Help please
# 1  
Old 06-08-2009
need to get a portion of entries in file based on a criteria --- Help please

All,


Below is the file, what i need to do is take the text in between the /*-- and --*/ , i mean the jobs. Then i have grep for system name . If the job is there in system 1 i have to print to a file.

Basically i want to take all the jobs that are in system1 to another file . because the below file autosys_file will jobs in all system i want extract the jobs that are in system1.

Please help this is urgent request ...

FILE ---------autosys_file-----

/* ----------------- test_syssystem_job ----------------- */

insert_job: test_syssytem2_job job_type: c
command: /bin/echo "AUTOSYS install test on system2 10/10/99"
machine: system2
#owner: autosys@system2
permission: gx,ge,wx,we
std_out_file: /tmp/dd.out
std_err_file: /tmp/ddd.err
alarm_if_fail: 1


/* ----------------- test_syssystem3_job ----------------- */

insert_job: test_syssystem3_job job_type: c
command: /bin/echo "AUTOSYS install test on system3 10/10/99"
machine: system3
#owner: autosys@system3
permission: gx,ge,wx,we
std_out_file: /tmp/qqq.out
std_err_file: /tmp/ggg.err
alarm_if_fail: 1


/* ----------------- get_name_system4_job ----------------- */

insert_job: get_name_system4_job job_type: c
command: /bin/echo "AUTOSYS install test on system4 10/10/99"
machine: system4
#owner: autosys@system4
permission: gx,ge,wx,we
std_out_file: /tmp/ggg.out
std_err_file: /tmp/ggg.err

/* ------------------ ...
...
...
# 2  
Old 06-08-2009
what have you tried?
# 3  
Old 06-08-2009
I have tried to do it AWK, but no use, i am not expert in AWK. I planned to write a script to read the line inbetween the /* and /* and then write to a file and grep the system anme in the file and write another file. But i think this is complicated
# 4  
Old 06-08-2009
Quote:
Originally Posted by arunkumar_mca
I have tried to do it AWK, but no use, i am not expert in AWK. I planned to write a script to read the line inbetween the /* and /* and then write to a file and grep the system anme in the file and write another file. But i think this is complicated
nobody is an expert in everything at first. what really matters is whether one wants to make effort in learning. Have you read the Awk manual since 2004??( It doen't take a month to finish the whole document.) you are already not a newbie and in your previous posts you are exposed to shell scripting (since 2004??) so i would expect you to produce something, even if its not working , show how its not working...or errors you are getting...
# 5  
Old 06-08-2009
Thank you , I need to produce this as fast as i can . I can do the scripting parallely. If any of you guys have idea or the script please pass it to me.

this is the awk script , that will take the line between /* and /* , This is working with one entries, if it is a muliple entry i an struct with the loop to get all the line


#!/bin/ksh
awk '\
//*/,//*/ {
if (match($0,"/*"))
print substr($0,index($0,"/*"))
else
if (match($0,"/*"))
print substr($0,1,index($0,"/*")-1)
else
print
}' test_out

Last edited by arunkumar_mca; 06-08-2009 at 10:58 PM..
# 6  
Old 06-08-2009
what is the expected output you want to see from the sample you gave? i don't see system 1 anywhere.
# 7  
Old 06-08-2009
This is the part of the script to get the line inbetween /* and /*, i will redirect that to test out file , and i need to greo system,

Can you tell me how to loop the /* line in files
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remove lines from File.A based on criteria in File.B

Hello, I have two files of the following form. I would like to remove from File.A where the first three colum matches values in File.B to give the output in File.C File.A 121 54321 PQR CAT 122 765431 ABC DOG 124 98765 ZXY TIGER 125 86432 GEF LION File.B 122 765431 ABC 125 86432 GEF... (4 Replies)
Discussion started by: Gussifinknottle
4 Replies

2. Shell Programming and Scripting

Awk/sed/cut to filter out records from a file based on criteria

I have two files and would need to filter out records based on certain criteria, these column are of variable lengths, but the lengths are uniform throughout all the records of the file. I have shown a sample of three records below. Line 1-9 is the item number "0227546_1" in the case of the first... (15 Replies)
Discussion started by: MIA651
15 Replies

3. Shell Programming and Scripting

awk to print specific line in file based on criteria

In the file below I am trying to extract a specific instance of path, if the adjacent plugin": "/rundb/api/v1/plugin/49/. Thank you :). file "path": "/results/analysis/output/Home/Auto_user_S5-00580-4-Medexome_65_028/plugin_out/FileExporter_out.52", "plugin": "/rundb/api/v1/plugin/49/",... (8 Replies)
Discussion started by: cmccabe
8 Replies

4. Shell Programming and Scripting

Match based on criteria to file

Trying to match $1 of target.txt to $5 of file.txt. If there is a match then in an output.txt file $1,$1 (row underneath),$6,$4,$7 from file.txt are printed on the same line as $1 of target.txt. The input is from excel and the output should be tab-deliminated. Thank you :). target.txt... (2 Replies)
Discussion started by: cmccabe
2 Replies

5. Shell Programming and Scripting

Copying section of file based on search criteria

Hi Guru's, I am new to unix scripting. I have a huge file with user details in it(file2) and I have another file with a list of users(file1). Script has to search a user from file1 and get all the associated lines from file2. Example: fiel1: cn=abc cn=DEF cn=xyx File 2: dn:... (10 Replies)
Discussion started by: Samingla
10 Replies

6. Shell Programming and Scripting

Select lines from a file based on a criteria

Hi I need to select lines from a txt file, I have got a line starting with ZMIO:MSISDN= and after a few line I have another line starting with 'MOBILE STATION ISDN NUMBER' and another one starting with 'VLR-ADDRESS' I need to copy these three lines as three different columns in a separate... (3 Replies)
Discussion started by: Tlcm sam
3 Replies

7. Shell Programming and Scripting

Extract error records based on specific criteria from Unix file

Hi, I look for a awk one liner for below issue. input file ABC 1234 abc 12345 ABC 4567 678 XYZ xyz ght 678 ABC 787 yyuu ABC 789 7890 777 zxr hyip hyu mno uii 678 776 ABC ty7 888 All lines should be started with ABC as first field. If a record has another value for 1st... (7 Replies)
Discussion started by: ratheesh2011
7 Replies

8. Shell Programming and Scripting

Rename portion of file based on another file

Hello, I've been searching and reading, but I can't figure out how to solve this problem with my newbie skills. In my directory, I have a list of files (see dirlist.txt attachment) that I need to merge and rename. I have part of the code of the code figured out (see below). However, I... (3 Replies)
Discussion started by: anjulka
3 Replies

9. Shell Programming and Scripting

split large file based on field criteria

I have a file containing date/time sorted data of the form ... 2009/06/10,20:59:59.950,XAG/USD,Q,1,1115, 14.3025,100,1,1 2009/06/10,20:59:59.950,XAG/USD,Q,1,1116, 14.3026,125,1,1 2009/06/10,20:59:59.950,XAG/USD,R,0,0, , 0,0,0 2009/06/10,20:59:59.950,XAG/USD,R,1,0, 14.1910,100,1,1... (6 Replies)
Discussion started by: asriva
6 Replies

10. Shell Programming and Scripting

Select a portion of file based on query

Hi friends :) I am having a small problem and ur help is needed... I have a long file from which i want to select only some portions after filtering (grep). My file looks like : header xxyy lmno xxyy wxyz footer header abcd xy pqrs footer . . (14 Replies)
Discussion started by: vanand420
14 Replies
Login or Register to Ask a Question