Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-07-2004, 06:23 AM
|
#1
|
|
Member
Registered: Nov 2004
Posts: 101
Rep:
|
A cool script to search within a hell of TXT files
Hi.
I've got 1000s of TXT files within a directory, and I would like to
find
a cool script to search within it.
I want to search files which content 'Foo' but not 'John', and only
within the '20041129' subdirectory.
I don't know if I must develop my own script or it already exists.
BTW, can I integrate this script into a Apache module?
Thank you very much.
|
|
|
|
12-07-2004, 06:39 AM
|
#2
|
|
Senior Member
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357
Rep:
|
grep -r foo 20041129/ | grep -v john
To integrate this into apache, make script containing lines:
Code:
#!/bin/sh
echo -e 'Content-Type: text/plain\n\n'
grep -r foo 20041129/ | grep -v john
|
|
|
|
12-07-2004, 06:39 AM
|
#3
|
|
Member
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720
Rep:
|
Hey
You could just grep through it to find which files contain "foo", but not "John". If you cat the result to a text file which will show you the path.
Code:
$ echo "$(grep -Eir Foo /home/guarriman/20041129/* | grep -Eirv John)" > temp_file
This will put all the output in "temp_file" and will show you the path.
You could also find a way just to print the path, but i don't know how to do that atm.
Hope this helps.
hamish
|
|
|
|
12-07-2004, 06:40 AM
|
#4
|
|
Member
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720
Rep:
|
lol, I see I was too late.
H
|
|
|
|
12-07-2004, 06:41 AM
|
#5
|
|
Member
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720
Rep:
|
ToniT,
how do you integrate that code into apache? Is it possible to create a web page whereby someone clicks a "show me all file containing Foo" link, and that code is executed.
That seems quite insecure, though.
Hamish
|
|
|
|
12-08-2004, 12:17 AM
|
#6
|
|
Senior Member
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357
Rep:
|
Hamish:
By saving that file to eg. foo.cgi and enabling cgi support from apache.
|
|
|
|
12-08-2004, 03:48 AM
|
#7
|
|
Member
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720
Rep:
|
and then do you have a link which calls the foo.cgi file?
H
|
|
|
|
12-08-2004, 07:21 AM
|
#8
|
|
Senior Member
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357
Rep:
|
test it.
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:25 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|