• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Seraching for files in directory

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use: find /path filename
 
Saloon Keeper
Posts: 29003
214
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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" *
 
author and iconoclast
Posts: 24208
47
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic