bugfindutils - Bugs: bug #44570, Wrong find -type f -not -name...


bug #44570: Wrong find -type f -not -name "*txt" result for files with weird names

Submitted by:  Jan Kocoń <kotu88>
Submitted on:  Wed 18 Mar 2015 02:29:04 PM UTC  
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  None
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  4.4.2 Fixed Release:  None

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Wed 18 Mar 2015 04:17:08 PM UTC, comment #2:

Yes, LC_ALL=C solved this problem. It is not a bug in 'find'. Thank you!

Jan Kocoń <kotu88>
Wed 18 Mar 2015 03:08:00 PM UTC, comment #1:

Try again, using: LC_ALL=C find -type f -not -name '*.txt'

My guess is that you are in a non-C multibyte locale, and that the filenames being printed are ones that are invalid when interpreted in the multibyte encoding rules of your current locale. globbing is only required to work on valid encoded content, so the fact that you have a name that is not a valid encoding means that the glob cannot match it, and therefore it gets printed even though it ends in a .txt ending. Switching to a locale where there are no encoding errors (such as LC_ALL=C) will avoid the problem.

Oh, and don't use: -name .txt. You WANT to use -name '.txt' (so that the shell is not expanding the glob prior to calling find, but rather that find is being given a literal glob to expand itself).

Eric Blake <ericb>
Project Administrator
Wed 18 Mar 2015 02:29:04 PM UTC, original submission:

When I type
find -type f -not -name "*txt"
or even:
find -type f -not -name *txt
on my data, there is a problem with some files (I attached a small subset of that data). There is a result below:
kotu@..../tmp$ find -type f -not -name *.txt
./http___lancuchy_net_/kolko-do-kluczy-10-xl.htm?st=?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%82a?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%84cuch ogniwo ?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%9Br.plain.txt
./http___lancuchy_net_/kolko-do-lancucha-10x60w-irma.htm?st=?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%82a?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%84cuch ogniwo ?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%9Br.plain.txt
./http___lancuchy_net_/lancuch-niezgrzewany-12mm-bialy.htm?st=?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%82a?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%84cuch ogniwo ?%84?%82?%82?%84?%84š?%84?%84?%84?%82?%82?%82?%82?%82?%82?%9Br.plain.txt

These files shouldn't be in output, am I right?

Jan Kocoń <kotu88>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #33389:  tmp.7z added by kotu88 (269KiB - application/x-7z-compressed)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by ericb (Posted a comment)
  • -email is unavailable- added by kotu88 (Submitted the item)
  • -email is unavailable- added by kotu88

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-03-18 kotu88 Attached File- => Added tmp.7z, #33389
        Carbon-Copy- => Added -email is unavailable-

    Back to the top

    Powered by Savane 3.4