command for selecting specific lines from a script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers command for selecting specific lines from a script
# 1  
Old 05-11-2008
command for selecting specific lines from a script

I need help on following script:



I need to print the lines which are in bold letters in separate file as

record

string("|") emp_name;

string("|") emp_id;

decimal("|") emp_salary;

string("|") emp_status;

string("\n") emp_proj;

end



Above lines are related to file ${_AB_PROXY_DIR}"'/rf_emp_status_emp_proj-3.dml which is present in 19 th line in below script.

The issue is i need to print only specific lines which are in bold letters in separate file. In below script you will find one field record which will be repeating more times . I need to select all that that lines fromrecord field to end of file ${_AB_PROXY_DIR}"'/rf_emp_status_emp_proj-3.dml.



Please can you help on sending that bold letter fields into separate file.
I am highliting all that lines in below script wich i want in seperate file, in red color


print -r -- 'record

string("|") emp_name;

string("|") emp_id;

decimal("\n") emp_salary;

end' > "${_AB_PROXY_DIR}"'/in_emp_data-1.dml'

print -r -- '/*Reformat operation*/

out::reformat(in) =

begin

out.*:: in.*;

out.emp_status :: if(next_in_sequence()<3) "A" else "D";

out.emp_proj :: "ABC";

end;' > "${_AB_PROXY_DIR}"'/rf_emp_status_emp_proj-2.xfr'

print -r -- 'record

string("|") emp_name;

string("|") emp_id;

decimal("|") emp_salary;

string("|") emp_status;

string("\n") emp_proj;

end
;' > "${_AB_PROXY_DIR}"'/rf_emp_status_emp_proj-3.dml'

print -r -- '/*Reformat operation*/

out::reformat(in) =

begin

out.*:: in.*;

out.emp_loc :: "USA";

end;' > "${_AB_PROXY_DIR}"'/rf_emp_location-4.xfr'

print -r -- 'record

string("|") emp_name;

string("|") emp_id;

string("|") emp_salary;

string("|") emp_status;

string("|") emp_proj;

string("\n") emp_loc;

end;' > "${_AB_PROXY_DIR}"'/rf_emp_location-5.dml'

Thanks,
gangadhar.
# 2  
Old 05-13-2008
What's the criterion for deciding which part of the file to extract? The name of the output file?

Code:
perl -0777 -pe "s%;' > \"\\$\\{_AB_PROXY_DIR\\}\"'/rf_emp_status_emp_proj-3.dml'.*%%s;
s/^.*print -r -- '//s" file

This reads in the whole file, and replaces everything from the matching file name through the end of file with nothing, then everything up through the last "print -r -- '", and prints whatever remains. The quoting got a bit tricky, with lots of ugly backslashes; there are ways to make that more elegant, but hopefully this should at least get you started.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Selecting specific variable in log file

Hi there I am trying to look for a specific word in the log file and I am aware this can be done by grep for example. As there will be multiple entries for this I want to grep the last one to enter the log... how would I go about this - would I have to use tail? Thanks in advance Alex (4 Replies)
Discussion started by: simpsa27
4 Replies

2. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

3. Shell Programming and Scripting

selecting and deleting specific lines with condition

I have a set of data as below: The first field, $1 represent "|". The $3 (3rd field) and $6 (6th field) in my data file represent "number-molecule" which has arrangement as below: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ... (9 Replies)
Discussion started by: vjramana
9 Replies

4. Shell Programming and Scripting

selecting specific fields in a file (maybe with sed?)

Hi, I have a file with following lines: chr1 10 AC=2;AF=1.00;AN=2;DP=2;Dels=0.00;HRun=0;HaplotypeScore=0.00;MQ=23.00;MQ0=0;QD=14.33;SB=-10.01 chrX 18 AB=0.52;AC=1;AF=0.50;AN=2;DP=203;DS;Dels=0.00;HRun=0;HaplotypeScore=20.01;MQ=15.63;MQ0=85;QD=12.80;SB=-1289.58 I need to extract 4... (2 Replies)
Discussion started by: menenuh
2 Replies

5. Shell Programming and Scripting

Selecting specific 'id's from lines and columns using 'SED' or 'AWK'

Hello experts, I am new to this group and to 'SED' and 'AWK'. I have data (text file) with 5 columns (C_1-5) and 100s of lines (only 10 lines are shown below as an example). I have to find or select only the id numbers (C-1) of specific lines with '90' in the same line (of C_3) AND with '20' in... (6 Replies)
Discussion started by: kamskamu
6 Replies

6. UNIX for Dummies Questions & Answers

Selecting specific line using awk

Hi, I would like to get the specific line from the file taking specific coloumn as reference. Thanks and Regards (1 Reply)
Discussion started by: kkarthik_kaja
1 Replies

7. Shell Programming and Scripting

Selecting rows with a specific criteria

Hi, I want a UNIX command that can filter out rows with certain criteria. The file is tab deliminated. Row one is just a value. Basically what I want to do is select based on the name and character at the end (o). So lets lets say i want a row that has WashU and (o) then it would print... (2 Replies)
Discussion started by: phil_heath
2 Replies

8. Programming

selecting rows with specific IDs for downstream analysis

Hi, I'm working hard on SQL and I came across a hurdle I'm hoping you can help me out with. I have two tables table1 headers: chrom start end name score strand 11 9720685 9720721 U0 0 + 21 9721043 9721079 U0 0 - 1 9721093 9721129 U0 0 + 20 ... (2 Replies)
Discussion started by: labrazil
2 Replies

9. UNIX for Dummies Questions & Answers

Help with selecting specific lines in a large file

Hello, I need to select the 3 lines above as well as below a search string, including the search string. I have been trying various combinations using sed command without any success. Can anuone help please. Thanking (2 Replies)
Discussion started by: tansha
2 Replies

10. Shell Programming and Scripting

Urgent: selecting unique specific content of a file using shell script

Hi, I have a file whose content and format at places is as given below. print coloumn .... coloumn .... coloumn .... skip 1 line print coloumn ... skip 1 line I need to select the following : print coloumn .... coloumn .... coloumn... (2 Replies)
Discussion started by: jisha
2 Replies
Login or Register to Ask a Question