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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-21-2006, 04:18 AM
|
#1
|
Member
Registered: Sep 2004
Location: Melbourne, Victoria Australia
Distribution: Support those that support you :)
Posts: 872
Rep:
|
Grep String Search, and identify source file.
hey
i havent figured what string of pipes and Command will allow me to display the filename in which 'grep string' finds.
cat *.fxd | grep Comedy
Code:
<genre>Adventure / Comedy</genre>
<genre>Comedy</genre>
<genre>Comedy / Drama</genre>
<genre>Adventure / Comedy</genre>
<genre>Action / Adventure / Comedy</genre>
<genre>Comedy</genre>
<genre>Comedy</genre>
<genre>Comedy</genre>
<genre>Action / Comedy / Crime</genre>
how can i show the above seperated by it's filename. or even grab the file name
Note i find the solution script will be, very interesting to locate what file store what settings
|
|
|
01-21-2006, 04:43 AM
|
#2
|
Senior Member
Registered: Aug 2005
Posts: 1,755
Rep:
|
|
|
|
01-21-2006, 05:32 AM
|
#3
|
Member
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553
Rep:
|
If you're interested in what files match your search string but not exactly how they match, use the -l switch, like so: grep -l string files. In your case: grep -l Comedy *.fxd
|
|
|
01-21-2006, 06:55 AM
|
#4
|
Senior Member
Registered: Nov 2002
Location: British Columbia, Canada
Distribution: Gentoo x86_64; FreeBSD; OS X
Posts: 3,764
Rep:
|
From grep manpage:
Quote:
-l, --files-with-matches
Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match.
|
I don't think that's what he wants. spooon's answer is correct, because by default grep will print the filename on multiple file searches. The reason it isn't working for carl0ski is because of the RUOC (redundant use of 'cat') which means grep is being run individually for each file catted, rather than a single run.
So, as spoon so helpfully wrote:
will do the trick...
|
|
|
01-21-2006, 09:15 AM
|
#5
|
Member
Registered: Sep 2004
Location: Melbourne, Victoria Australia
Distribution: Support those that support you :)
Posts: 872
Original Poster
Rep:
|
Quote:
Originally Posted by bulliver
From grep manpage:
I don't think that's what he wants. spooon's answer is correct, because by default grep will print the filename on multiple file searches. The reason it isn't working for carl0ski is because of the RUOC (redundant use of 'cat') which means grep is being run individually for each file catted, rather than a single run.
So, as spoon so helpfully wrote:
will do the trick...
|
i really can't believe i was that stupid i completely over complicated it somehow :S.
|
|
|
All times are GMT -5. The time now is 03:39 PM.
|
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
|
|