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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] How to print specific text from a file?
# 1  
Old 09-09-2013
[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.

Code:
 
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
############## 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.g...rvlet/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

Code:
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
# 2  
Old 09-09-2013
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.
# 3  
Old 09-09-2013
What was the solution then?
# 4  
Old 09-09-2013
Hello Vbe,

Actually I was writing the below code.

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.



Code:
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

# 5  
Old 09-09-2013
Thanks for sharing !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

2. Shell Programming and Scripting

Match text from file 1 to file 2 and return specific text

I hope this makes sense and is possible. I am trying to match $1 of panel_genes.txt with $3 of RefSeqGene.txt and when a match is found the value in $6 of RefSeqGene.txt Example: ACTA2 is $1 of panel_genes.txt ACTA2 NM_001613.2 ACTA2 NM_001141945.1 awk 'FNR==NR {... (4 Replies)
Discussion started by: cmccabe
4 Replies

3. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

4. Shell Programming and Scripting

[Solved] awk compare two different columns of two files and print all from both file

Hi, I want to compare two columns from file1 with another two column of file2 and print matched and unmatched column like this File1 1 rs1 abc 3 rs4 xyz 1 rs3 stu File2 1 kkk rs1 AA 10 1 aaa rs2 DD 20 1 ccc ... (2 Replies)
Discussion started by: justinjj
2 Replies

5. Shell Programming and Scripting

[solved] how to get specific env variable values into a file

greetings! how do i get an env variable that looks like this when echoed: into a file that looks like this: keeping in mind that the two constants are the fields from the env variable will always be in odd positions of the string that need to go into the file AND they will always start... (3 Replies)
Discussion started by: crimso
3 Replies

6. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

7. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

8. Shell Programming and Scripting

[Solved] Find Specific records from file and add totals into variables

Hi Eveyone, I am working on one shell script to find the specific records from data file and add the totals into variables and print them. you can find the sample data file below for more clarification. Sample Data File: PXSTYL00__20090803USA CHCART00__20090803IND... (7 Replies)
Discussion started by: veeru
7 Replies

9. Shell Programming and Scripting

Adding specific text and spaces to each line in a text file

Hi, I wanted to add specific text to each row in a text file containing three rows. Example: 0 8 7 6 5 5 7 8 9 0 7 9 7 8 9 0 1 2 And I want to add a 21 at the beginning of the first row, and blank spaces at the beginning of the second two rows. To get this: 21 0 8 7 6 5 5 7 8... (4 Replies)
Discussion started by: hertingm
4 Replies

10. UNIX for Dummies Questions & Answers

search and replace a specific text in text file?

I have a text file with following content (3 lines) filename : output.txt first line:12/12/2008 second line:12/12/2008 third line:Y I would like to know how we can replace 'Y' with 'N' in the 3rd line keeping 1st and 2nd lines same as what it was before. I tried using cat output.txt... (4 Replies)
Discussion started by: santosham
4 Replies
Login or Register to Ask a Question