Re: searching a directory sub-tree.

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

 



On 3/27/25 10:29 PM, Jon LaBadie wrote:
On Wed, Mar 26, 2025 at 03:00:21PM -0600, home user via users wrote:
Good afternoon,

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

(but without the brackets).  This often works.  But it sometimes fails when the search string contains "printable" characters other than letters and digits.  Examples of both:

bash.32[.Organ]: find . -type f -print | xargs grep -l D-_qS_3KXBA /dev/null
./organ_dir.txt
bash.33[.Organ]: find . -type f -print | xargs grep -l -ob9LHPEaKY /dev/null
grep: conflicting matchers specified
bash.34[.Organ]: find . -type f -print | xargs grep -l "-ob9LHPEaKY" /dev/null
grep: conflicting matchers specified
bash.35[.Organ]:
bash.35[.Organ]:
bash.35[.Organ]:

bash.36[.Organ]: find . -type f -print | xargs grep -l '-ob9LHPEaKY' /dev/null
grep: conflicting matchers specified
bash.37[.Organ]:

How do I get this to work even when the search string includes (especially starts with) printable characters other than digits and letters?


Your search strings look like options.  For example, -ob9... looks
like the -o option, not a search string.

A very common way around this is to use "--" at the end of
your options.  Many commands recognize the solo double dash
to mean no more options follow.  So:

   find . -type f -print | xargs grep -l -- '-ob9LHPEaKY' /dev/null

should work.

Thank-you, Jon.
That works, and it also works if I use "grep" directly (no "find").

--
_______________________________________________
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