PHP Script to search muliplte files Urgent


 
Thread Tools Search this Thread
Top Forums Web Development PHP Script to search muliplte files Urgent
# 1  
Old 05-04-2009
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  
Old 05-20-2009
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 07:42 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

2. Shell Programming and Scripting

Urgent...Need a shell script to list files which belong to particular groups

Hi, I am just new to scripting but got to write a complex scipt please help. i need a shell script which can check the list of data listed in a txt doc and see if they belong to any of the groups that are listed in other list file.... (5 Replies)
Discussion started by: draghun9
5 Replies

3. UNIX for Dummies Questions & Answers

Script to search and copy files

HI everyone, I been to this site before for help and found my answers on other threads now I am posting my own :). I have a list of file names with out extensions on an txt file. I need a way for the script to search on the server for each file name and copy the files over to a new directory.... (12 Replies)
Discussion started by: sergiol
12 Replies

4. Shell Programming and Scripting

URGENT!!! bash script to sort files into folder according to a string in the filename

Hi all. I am very new to linux scripting and i have a task i can only solve with a script. I need to sort files base on the date string in their filenames and create a folder using the same date string then move the files to their respective folders. Scenario: Folder Path:... (1 Reply)
Discussion started by: ace47
1 Replies

5. Shell Programming and Scripting

open 2 files and compare values script - urgent

Hi gurus I have two csv files that are outputs. The file contains data similar to s.no,number1,number2,date1 -------------------------------- 1, a123,482.29,11/28/07 13:00 2,a124,602.7,9/24/07 14:00 3,a125,266.93,10/9/07 16.48 4,a126,785.15,11/14/07 16:08 <file 2> s.no name... (2 Replies)
Discussion started by: inkyponky
2 Replies

6. Shell Programming and Scripting

URGENT: Script/Function needed to read text property files in block wise

Hi, Iam in a need for a script/function in KSH where I want to read a text file (property file) in block by block. Here is the example: Heading Name Descripton Block Block1 Value1 Description Property Name Value Property Name Value Property Name Value Property Name Value Property Name... (7 Replies)
Discussion started by: ysreenivas
7 Replies

7. Shell Programming and Scripting

Script to archive log files:Urgent Help required

I have no prior knowledge of Unix shell scripting,but my requriment demands to wrie a script that do fallowing things. 1.Delete older than one year log files 2.Moves files in to the directories as YYYYMM wise. 3.If files in $LOGDIR older than n=2 months tar and move them to $ARCHIVEDIR... (5 Replies)
Discussion started by: vamsx
5 Replies

8. Shell Programming and Scripting

Urgent !!! Shell script to copy files to VSS

Hi all !!! I need this sample script urgently. Please help. Suppose I do an "ls -ltr" in a directory and store the output in a text file (say "a.txt"). What I need to do is to write a shell script which reads file-names from "a.txt" and copies only those files to VSS. Let's say the destination... (1 Reply)
Discussion started by: devalin
1 Replies
Login or Register to Ask a Question