The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics 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 06:29 AM
Help with selecting specific lines in a large file tansha UNIX for Dummies Questions & Answers 2 02-06-2008 08:26 AM
Urgent: selecting unique specific content of a file using shell script jisha Shell Programming and Scripting 2 01-08-2008 08:45 AM
need help--script to filter specific lines from multiple txt files I-1 Shell Programming and Scripting 7 02-16-2007 08:42 PM
Shell Script to read specific lines in a file varshanswamy Shell Programming and Scripting 5 08-22-2005 07:12 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-11-2008
gardasgangadhar gardasgangadhar is offline
Registered User
  
 

Join Date: May 2008
Posts: 1
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 (permalink)  
Old 05-13-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

BB 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 -4. The time now is 05:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0