The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > Web Programming, Web 2.0 and Mashups
.
google unix.com



Web Programming, Web 2.0 and Mashups Discuss Web Programming and Web Server Administration, including LAMP, Apache, MySQL, Flash, HTML, SEO, Mashups and other Web APIs and topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
URGENT: Script/Function needed to read text property files in block wise ysreenivas Shell Programming and Scripting 7 05-11-2009 03:08 AM
csh script to search for files and display result neillsm Shell Programming and Scripting 4 03-08-2009 12:05 PM
Script to archive log files:Urgent Help required vamsx Shell Programming and Scripting 5 07-30-2008 06:34 AM
Search files with specfic extention and later search content lovi_v UNIX for Advanced & Expert Users 2 07-14-2008 12:05 PM
Urgent !!! Shell script to copy files to VSS devalin Shell Programming and Scripting 1 08-20-2007 06:16 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-04-2009
krabu krabu is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 44
PHP Script to search muliplte files Urgent

Hi,
I have multiplte text files containing numbers e:g

123400 0000001
000001 2333334

I am taking input from html form and passing to php script using post.
I want to search multiple files if input is found then display the line
containing the input.
Thanks in advance.
  #2 (permalink)  
Old 05-20-2009
timgolding timgolding is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 34
How much have you done. Have you got any of this in place? You can search for the numbers and display the line easily enough with preg_match

PHP Code:
$numbers_to_search '123400 0000001';
$file_to_search 'path_to_file';

$numbers_to_search str_replace(" ""\s"$numbers_to_search);
$str=$file_get_contents($file_to_search);
if(
preg_match_all("/(\r\n|\n|\r).*".$str.".*(\r\n|\n|\r|$)/u"$str$matches))
{
     
print_r($matches);

Is it always going to be number though. or could it be any text to search. If it could be any text then using a regex might not be so useful. Maybe using the file command would be better

Last edited by timgolding; 05-20-2009 at 06:42 AM..
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0