permaculture playing cards*
The moose likes Linux / UNIX and the fly likes Seraching for files in directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Seraching for files in directory" Watch "Seraching for files in directory" New topic
Author

Seraching for files in directory

Gemini Moses
Ranch Hand

Joined: Jan 04, 2001
Posts: 245
How do I serach for all the files contaning ,
name="vvvvv"
in a particular directory?
I tried
grep -l name="vvvvv" *
but seems like due to " this is not giving correct output.
Thanks!
Greg Harris
Ranch Hand

Joined: Apr 12, 2001
Posts: 1012
use: find /path filename


what?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

There's a bit of a split in meaning there. That can be read as either "In a directory, filenames containing "vvvvv'", or it can be read as "files in a directory containing the value "vvvvv".
One way to match simple patterns is via globbing:
ls **vvvvv**
Will show all files where "vvvvv" is anywhere in the filename. For more complex patterns, pipe the output of the "find" command into grep:
find . | grep "vvvvv"
To find occurrances of "vvvvv" IN files in a directory, just use grep:
grep "vvvvv" *


Customer surveys are for companies who didn't pay proper attention to begin with.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

I think he wants files that contain the exact string
name="vvvvv"
quotes and all. The easiest way to do this would be to use single quotes to
surround the grep pattern:
grep 'name="vvvvv"' *
Single quotes prevent the shell from doing anything with the double quotes.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Seraching for files in directory