[Solved] How to print specific text from a file?

Hi All,

I have the below text file from which I have to cut particular section starting from PTR_Security_Rpeorting.cpf to PTR_Security_Reporting_Env93_export.

 
Report Model............: "D:\Cognos_Publishing\tmp.a2R94KLQec"\PTR_Security_Reporting.cpf
Report Output Script....: "D:\Cognos_Publishing\tmp.a2R94KLQec"\cognos_action_log.xml
Running command "D:\Cognos10FrameworkManager\cognos\c10\bin\BmtScriptPlayer" -n -s "env41_ldap-int" -u "cognos_builder" -p "bui@1d123" -m ""D:\Cognos_Publishing\tmp.a2R94KLQec"\PTR_Security_Reporting.cpf" -a ""D:\Cognos_Publishing\tmp.a2R94KLQec"\cognos_action_log.xml"
An existing project is being opened.
D:\Cognos_Publishing\tmp.a2R94KLQec\PTR_Security_Reporting.cpf
############# Script Player #############
Transaction count: 3
 
Transaction: 1
Action: SetActiveLocale
SetActiveLocale successful, continuing...
Transaction: 2
Action: Modify
Modify successful, continuing...
Transaction: 3
Action: Publish
Publish successful, continuing...
Elapsed time:
    8 seconds.
.
End Time: Fri 09/06/2013  3:47:44.63
Cleaning up the temp directories..
cygwin warning:
  MS-DOS style path detected: D:\Cognos_Publishing\tmp.a2R94KLQec
  Preferred POSIX equivalent is: /cygdrive/d/Cognos_Publishing/tmp.a2R94KLQec
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    Chapter 3. Using Cygwin
Copying all Reports to a temp folder.....
Updating Drill through definitions...
Target is PTR_REPORTS_ENV93
delete_reports env42 /content/package[@name='PTR_Security_Reporting_Env93']
##############Deleting Reports from /content/package[@name='PTR_Security_Reporting_Env93'] in env42 ##################
deleteReports -s env41_ldap-int -u cognos_builder -p bui@1d123 -g http://cognos10-dev-mycant.cant.ca.gov:33640/p2pd/servlet/dispatch -t /content/package[@name='PTR_Security_Reporting_Env93']
Logon successful as cognos_builder
Deleted reports from /content/package[@name='PTR_Security_Reporting_Env93']
##############Adding Reports from Source contol to all package in environment env42##################
AddReportFromSC -s env41_ldap-int -u cognos_builder -i bui@1d123 -g http://cognos10-dev-mycant.cant.ca.gov:33640/p2pd/servlet/dispatch -n /content/package[@name='PTR_Security_Reporting_Env93'] -m /apps/PTR/tmp/security_matrix.9480.xls -x /apps/PTR/tmp/tmp.uutYd21271/
Logon Sucessfull
Opened Security Matrix
Successfully added Security Report Beneficiary Change to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Internal External User Login Activity to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Internal External User Config Changes to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Privileged User Config Changes to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Benefit Calculation Override to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Internal External User Object Access to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report HIPPA Information On User Views Or Changes to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Privileged User Login Activity to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report User Account Inactivity to the Content Manager
with the following roles
ISOF Reporting
Security Reporting
Reports Support
Technical Validation
Successfully added Security Report User Own Data Views or Changes to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Mycant User Added Or Removed to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Privileged User Object Access to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Exclusions to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
 
Total number of Reports Added are 13
Cleaning up the temp directories..
##############Repointing package link of the reports in the all package to for env42 ##################
UpdateReportPackage -f /content/package[@name='PTR_Security_Reporting_Env93']//report -t /content/package[@name='PTR_Security_Reporting_Env93'] -s env41_ldap-int -u cognos_builder -p bui@1d123 -g http://cognos10-dev-mycant.cant.ca.gov:33640/p2pd/servlet/dispatch
Logon successful as cognos_builder
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Beneficiary Change'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Internal External User Login Activity'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Internal External User Config Changes'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Privileged User Config Changes'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Benefit Calculation Override'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Internal External User Object Access'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report HIPPA Information On User Views Or Changes'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Privileged User Login Activity'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report User Account Inactivity'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report User Own Data Views or Changes'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Mycant User Added Or Removed'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Privileged User Object Access'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Exclusions'] is updated.
Done.
##############Exporting the all package for env93 in the dev environment##################
Export -a PTR_Security_Reporting_Env93_export -i prl_env93 -c PTR_Security_Reporting_Env93 -s env41_ldap-int -u cognos_builder -p bui@1d123 -g http://cognos10-dev-mycant.cant.ca.gov:33640/p2pd/servlet/dispatch
Exporting PTR_Security_Reporting_Env93_export ...
Export started on Fri Sep 06 03:49:10 PDT 2013
Successfully Exported PTR_Security_Reporting_Env93_export
############## SCPing the zip file from dev to the server lg666 ##################
complete
############## SCPing the zip file from dev to the server lgpl454 ##################
complete
##############Importing all Reports in the Target environment env93##################
Import -a PTR_Security_Reporting_Env93_export -i prl_env93 -c PTR_Security_Reporting_Env93 -d PTR_Security_Reporting_Env93 -s env93_ldap-int -u cognos_builder -p bui@1d3r$ -g http://cognos10-sim-mycant.cant.ca.gov:33680/p2pd/servlet/dispatch
Importing archive PTR_Security_Reporting_Env93_export... Please wait...
Setting Permissions on the imported Package
with the following roles
env93_ldap-int
env93_ldap-ext
Event was sucessful: eventID=19F3B8307F830CEB0140DAE37ECB80B500140f2e468b8
Import started on Fri Sep 06 03:49:56 PDT 2013
Successfully Imported PTR_Security_Reporting_Env93_export

I tried the below code but somehow not working for me

sed -n "/PTR_Security_Reporting/,/Successfully Exported PTR_Security*/p" input

---------- Post updated at 03:12 AM ---------- Previous update was at 02:18 AM ----------

Hello Moderator,

Please close this thread. I got the solution.

Thanks
Vikram

Mr. Vikram remember whenever you are posting on forum, please mention whats your input and and what output you expect from your input, show sample output to us, we cannot predict it. otherwise it will be very difficult for users to answer.

What was the solution then?

Hello Vbe,

Actually I was writing the below code.

sed -n "/PTR_Security_Reporting/,/Successfully Exported PTR_Security*/p" input

As there was multiple occurrence of PTR_Security_Reporting the code was not able to give me the text from the 1st occurrence of this string. I have changed that to PTR_Security_Reporting.cpf and it worked fine.

sed -n "/PTR_Security_Reporting.cpf/,/Successfully Exported PTR_Security*/p" input file
Report Model............: "D:\Cognos_Publishing\tmp.a2R94KLQec"\PTR_Security_Reporting.cpf
Report Output Script....: "D:\Cognos_Publishing\tmp.a2R94KLQec"\cognos_action_log.xml
Running command "D:\Cognos10FrameworkManager\cognos\c10\bin\BmtScriptPlayer" -n -s "env41_ldap-int" -u "cognos_builder" -p "bui@1d123" -m ""D:\Cognos_Publishing\tmp.a2R94KLQec"\PTR_Security_Reporting.cpf" -a ""D:\Cognos_Publishing\tmp.a2R94KLQec"\cognos_action_log.xml"
An existing project is being opened.
D:\Cognos_Publishing\tmp.a2R94KLQec\PTR_Security_Reporting.cpf
############# Script Player #############
Transaction count: 3
 
Transaction: 1
Action: SetActiveLocale
SetActiveLocale successful, continuing...
Transaction: 2
Action: Modify
Modify successful, continuing...
Transaction: 3
Action: Publish
Publish successful, continuing...
Elapsed time:
    8 seconds.
.
End Time: Fri 09/06/2013  3:47:44.63
Cleaning up the temp directories..
cygwin warning:
  MS-DOS style path detected: D:\Cognos_Publishing\tmp.a2R94KLQec
  Preferred POSIX equivalent is: /cygdrive/d/Cognos_Publishing/tmp.a2R94KLQec
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    Chapter 3. Using Cygwin
Copying all Reports to a temp folder.....
Updating Drill through definitions...
Target is PTR_REPORTS_ENV93
delete_reports env42 /content/package[@name='PTR_Security_Reporting_Env93']
##############Deleting Reports from /content/package[@name='PTR_Security_Reporting_Env93'] in env42 ##################
deleteReports -s env41_ldap-int -u cognos_builder -p bui@1d123 -g http://cognos10-dev-mycant.cant.ca.g...rvlet/dispatch -t /content/package[@name='PTR_Security_Reporting_Env93']
Logon successful as cognos_builder
Deleted reports from /content/package[@name='PTR_Security_Reporting_Env93']
##############Adding Reports from Source contol to all package in environment env42##################
AddReportFromSC -s env41_ldap-int -u cognos_builder -i bui@1d123 -g http://cognos10-dev-mycant.cant.ca.g...rvlet/dispatch -n /content/package[@name='PTR_Security_Reporting_Env93'] -m /apps/PTR/tmp/security_matrix.9480.xls -x /apps/PTR/tmp/tmp.uutYd21271/
Logon Sucessfull
Opened Security Matrix
Successfully added Security Report Beneficiary Change to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Internal External User Login Activity to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Internal External User Config Changes to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Privileged User Config Changes to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Benefit Calculation Override to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Internal External User Object Access to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report HIPPA Information On User Views Or Changes to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Privileged User Login Activity to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report User Account Inactivity to the Content Manager
with the following roles
ISOF Reporting
Security Reporting
Reports Support
Technical Validation
Successfully added Security Report User Own Data Views or Changes to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Mycant User Added Or Removed to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Privileged User Object Access to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
Successfully added Security Report Exclusions to the Content Manager
with the following roles
ISOF Reporting
Reports Support
Technical Validation
 
Total number of Reports Added are 13
Cleaning up the temp directories..
##############Repointing package link of the reports in the all package to for env42 ##################
UpdateReportPackage -f /content/package[@name='PTR_Security_Reporting_Env93']//report -t /content/package[@name='PTR_Security_Reporting_Env93'] -s env41_ldap-int -u cognos_builder -p bui@1d123 -g http://cognos10-dev-mycant.cant.ca.g...rvlet/dispatch
Logon successful as cognos_builder
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Beneficiary Change'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Internal External User Login Activity'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Internal External User Config Changes'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Privileged User Config Changes'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Benefit Calculation Override'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Internal External User Object Access'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report HIPPA Information On User Views Or Changes'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Privileged User Login Activity'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report User Account Inactivity'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report User Own Data Views or Changes'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Mycant User Added Or Removed'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Privileged User Object Access'] is updated.
/content/package[@name='PTR_Security_Reporting_Env93']/report[@name='Security Report Exclusions'] is updated.
Done.
##############Exporting the all package for env93 in the dev environment##################
Export -a PTR_Security_Reporting_Env93_export -i prl_env93 -c PTR_Security_Reporting_Env93 -s env41_ldap-int -u cognos_builder -p bui@1d123 -g http://cognos10-dev-mycant.cant.ca.g...rvlet/dispatch
Exporting PTR_Security_Reporting_Env93_export ...
Export started on Fri Sep 06 03:49:10 PDT 2013
Successfully Exported PTR_Security_Reporting_Env93_export

Thanks for sharing !