Re: Matching strings in a flat/text file?
| From: | Mark | Date: | Tue, 23 Oct 2001 18:59:25 +0000 |
| Subject: | Re: Matching strings in a flat/text file? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71984@lists.php.net to get a copy of this message | ||
On Mon, 22 Oct 2001 22:09:56 -0700, Nick Richardson wrote:
>Hey everyone,
>
>Anyone out there know how i could do this:
>
>I have a client who is an import car tuner. They would like to
>feature the
>cars they work on in their website. Instead of creating a new .html
>or .php
>file for every car they add to include the background setup, and the
>general
>content (type of car, owner, etc...) i want to put the information
>in to
>text file and search for it in there.
>
>So that's where i need help. I want to be able to put the info into
>a text
>file and pass the string to search for through the URL, then match
>everything between that line and an ending line in the text file,
>and print
>that out to the browser.
>
>Example: I want to pass a string using the URL
>(blah.php?car=civic_si) then
>search for ##civic_si in the text file, and print everything until
>it finds
>##end. So the text file will look like this:
>
>##civic_si
>This is my content, blah blah
>##end
>
>##nissan
>This is more content... yadda yadda
>##end
>
>Any ideas on how i can do this???
the easiest way would be with sed:
$data=
sed -n '/##civic_si/,/##end/p' $filename