• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

Searching for data inside a file

I have a script which read user input and append data to file. It is a html file. Now I need a script to search this file and print html page in returns.
The entires are separated by hardlines.
Is there a way to search such a file ?
Jerzy
0
jerzyk
Asked:
jerzyk
  • 3
1 Solution
 
vmpnCommented:
You cam search anything.  Could you be more specific about the file, that is the only way I might be able to provide you with complete solution.
0
 
Nathan Stanford SrSenior ProgrammerCommented:
Yes you can search it with newline as the seperator..  You first open the file then you read it in line by line.  The default for a each line is the Newline  which is a return character.

If you need help email me
nathan@cyberservices.com  - Home
nathan_stanford@cabp.com  - Work
A True Perl N. u T.
0
 
aurelioCommented:
That's  right - you can search it in many ways , I think there are at least 3 ways of doing it :
1) Use "grep" , it returns lines matching a word or a regular expression.
2) Use a shell script reading line by line , better a perl script
3) Use in C something like
while(fgets(buf,80,fp)!=NULL) if(strcmp(match,buf)) do_something() ;

0
 
Nathan Stanford SrSenior ProgrammerCommented:
I want to help it makes me a better programmer please send me a copy or a file with simular data with the info changed and I will make a script to fix the problem.
0
 
Nathan Stanford SrSenior ProgrammerCommented:
I want to help it makes me a better programmer please send me a copy or a file with simular data with the info changed and I will make a script to fix the problem.

If you need help email me
nathan@cyberservices.com - Home
nathan_stanford@cabp.com - Work
A True Perl N. u T.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now