The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
selecting only few lines from many based on a common pattern damansingh Shell Programming and Scripting 2 05-28-2008 03:29 AM
Help with selecting specific lines in a large file tansha UNIX for Dummies Questions & Answers 2 02-06-2008 04:26 AM
Urgent: selecting unique specific content of a file using shell script jisha Shell Programming and Scripting 2 01-08-2008 04:45 AM
need help--script to filter specific lines from multiple txt files I-1 Shell Programming and Scripting 7 02-16-2007 04:42 PM
Shell Script to read specific lines in a file varshanswamy Shell Programming and Scripting 5 08-22-2005 04:12 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-11-2008
Registered User
 

Join Date: May 2008
Posts: 1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-13-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,203
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 07:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102