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 9007201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:37:29+00:00 2026-06-16T01:37:29+00:00

I want to process PHP files on the content but i’m only interested in

  • 0

I want to process PHP files on the content but i’m only interested in the parts between < ?php … ?>. The rest should be removed and saved to a new file. Below I’ve already part of the code based on the code from this page multi line sed search. But it only gives the first part in .

start="<?php"
end="?>"
temp=$(sed -n '1h;1!H;${;g;s/.*'"$start"'//pI;d;}' <<< echo $filename)
output=$(sed -n '1h;1!H;${;g;s/'"$end"'.*//p;d;}' <<< "$temp")

Somebody has a solution? awk, grep is also oké. THanks

  • 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-16T01:37:30+00:00Added an answer on June 16, 2026 at 1:37 am

    this one-liner may work for you:

     awk '/<?php/{f=1} /?>/&&f{print;f=0} f'  file
    

    if you don’t want the <?php and ?> in output:

     awk '/<?php/{f=1;next;} /?>/&&f{f=0} f' file
    

    test: (I hope the output is what you are looking for. to save to new file, you could redirect output to a new file)

    kent$  cat test.txt 
    <?php
    all
    text
    
    here
    should
    be
    saved
    
    even if 
    
    empty
    
    lines
    
    ?>
    
    
    foo
    
    bar
    
    should be removed
    
    kent$  awk '/<?php/{f=1} /?>/&&f{print;f=0} f' test.txt                                                                                                                     
    <?php
    all
    text
    
    here
    should
    be
    saved
    
    even if 
    
    empty
    
    lines
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a c++ process, I want that process should always remain on foreground,
I have edited several files ISO-8859-15 encoded php source files with netbeans 6.7.1, but
I have two files, csform.php and process.php. Csform.php is the main page with the
I want to process MSXML which is generated by Visio 2010, Which Language will
I want to process large amount of small images on HDFS. Hadoop provides archive
I want to process every element of a for-loop. Taking this code, why is
I want to process a medium to large number of text snippets using a
I want to process a request header using a custom rewrite map. Therefore I
I want to process a file line by line in c, all lines in
I have the following XML and I want to process it so that I

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.