Re: searching a directory sub-tree.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 26, 2025 at 5:52 PM Samuel Sieb <samuel@xxxxxxxx> wrote:
>
> On 3/26/25 2:49 PM, Go Canes wrote:
> > On Wed, Mar 26, 2025 at 5:19 PM Jerry James <loganjerry@xxxxxxxxx> wrote:
> >>
> >> On Wed, Mar 26, 2025 at 3:01 PM home user via users
> >> <users@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> >>> I'm trying to search a directory sub-tree for a specific string.  I use this:
> >>>
> >>> find . -type f -print | xargs grep -l [string] /dev/null
> > [...]
> >>> How do I get this to work even when the search string includes (especially starts with) printable characters other than digits and letters?
> >>
> >> The problem is that those strings start with a '-', so grep thinks you
> >> are specifying more option.  Add -e before your search string:
> >>
> >> find . -type f -print | xargs grep -l -e -ob9LHPEaKY [dir]
> >>
> >> Also, you're working kind of hard here.  You might find grep's
> >> recursive search option a little easier to use:
> >>
> >> grep -rle -ob9LHPEaKY [dir]
> >
> > Or if you wish to use find, try "find . -type f -name '*ob9LHPEaKY*'".
> > Note that with the "*" wildcard you need to put the string in single
> > quotes.  If you want a case-insensitive match, use -iname instead of
> > -name.
>
> He's searching in the files, not searching for a filename.

Ah!  Missed that - sorry!

So use the recursive grep, or "find . -type f -name '*.txt' -exec grep
-l -- ob9LHPEaKY {} \;" to restrict it to just files with a .txt
extension.
-- 
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux