Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:39:30+00:00 2026-06-14T06:39:30+00:00

I have a file source.txt like the following: Executing resource: L:\Core\SQL\smpks_fcj_csdovdmt_addon.sql Failed to execute:

  • 0

I have a file source.txt like the following:

Executing resource: L:\Core\SQL\smpks_fcj_csdovdmt_addon.sql  
Failed to execute: 
Executing resource: L:\LC\SQL\lcpks_lcdtronl_utils.sql  
Executing resource: L:\LS\SQL\cspks_adhoc_charge_sch.sql  
Failed to execute:   
SHO ERR  
Executing resource: L:\LS\SQL\gwpks_ls_adhocsch_operations.sql  
Executing resource: L:\LS\SQL\lnpks_synd_services.sql  
Failed to execute:  
Executing resource: L:\LS\SQL\lspks_facility_contracts.sql  
Executing resource: L:\LS\SQL\lspks_fcj_lsdpxlog.sql  
Executing resource: L:\LS\SQL\lspks_lsdprmnt_kernel.sql  
Failed to execute:  
sho err;

From this file I need to get the lines just in front of the sting “Failed to execute:” and put it into a new file result.txt. One more condition, if “Failed to execute:” is followed by “sho err: or “SHO ERR” I dont need that file in the result. The output of the above mentioned file should be:

Executing resource: L:\Core\SQL\smpks_fcj_csdovdmt_addon.sql  
Executing resource: L:\LS\SQL\lnpks_synd_services.sql

Please help. Perl script or batch file or Ant script is fine.

If I get an option like, if “Sho err” is there, delete the previous line, its fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:39:31+00:00Added an answer on June 14, 2026 at 6:39 am

    This works for me:

    grep -B 1 "Failed" sources.txt  | grep "Executing resource:" > results.txt
    

    EDIT: to take into account he “SHO ERR” requirement, possibly it is better to use Perl:

    my @lines = <>;
    push @lines, "";
    push @lines, "";
    my $linesNum = @lines;
    for ( $i = 0; $i < $linesNum - 2; $i++) {
       if ($lines[$i+1] =~ /Failed to execute:/) {
         if (!($lines[$i+2] =~ /SHO ERR/i)) {
            print $lines[$i] if $lines[$i] =~ /^Executing/
         }
       }
     }
    

    you can use it like this:

    cat sources.txt | perl script.pl > results.pl
    

    or

    perl script.pl sources.txt > results.pl
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CMakeLists.txt file that looks like this: add_executable(exec1 exec1.c source1.c source2.c source3.c)
I have a txt file which actually is a html source of some webpage.
I have many source/text file, say file.cpp or file.txt . Now, I want to
Let's say you have a text file like this one: http://www.gutenberg.org/files/17921/17921-8.txt Does anyone has
I'm have some data in a txt file like in this form | item_id
i have a text (text.txt) file like this: shir beer geer deer i have
i have some text file which contain proxy ip . which look like following
Suppose I have an object file ( source.o ) without function main . a
I have a source file, openpage.pl, where I call use_module/1 to import SWI-Prolog's http_open/3:
I have a source file where 2 features have been added. In order to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.